Skip to main content
April 9, 2025
Question

Function need to evaluate the expression

  • April 9, 2025
  • 4 replies
  • 0 views

Hey,

I am exploring some thing new in Appain functions,
Supose if user enter 1+2+3+4+5 in a text box then is there any function to evaluate this and give me the sum of all those numbers as 15.

Thanks in advance.

4 replies

mathieud0001
April 9, 2025

a!localVariables(
  local!text: "1+2+3+4+5",
  local!textItems: split(local!text, "+"),
  local!textItemsInteger: tointeger(local!textItems),
  sum(local!textItemsInteger)
)

Yeah, you could do that. But I don't know, seems a little brittle. Seems like something that may be better suited for an LLM.

April 10, 2025

Hey [mention:f5e81b8502fa4e77ad12697686a4fc56:e9ed411860ed4f2ba0265705b8793d05] 

Thanks for your response.

This will only work for sum of numbers but what I need is to calculate the whole expression which includes mathematical operations like +,-,/,*
Example... If user enters 5*2+1-10/2 then the result should be 6.

stefanhelzle0001
April 10, 2025

There is no such function in Appian. And parsing this manually becomes a pain quickly as you need to evaluate the operations in the right order.