Setting a value to a numeric addition actually concatenates strings [was: Bug Report from aschoijett #2021-6-4_14-50-30]

OS info

  • Operating System : Windows 10.0.19042
  • Wappler Version : 3.9.9

Problem description

Setting a value to a numeric addition actually concatenates strings.

Steps to reproduce

  1. In a server-side API, create a step to Set Value of a variable called Addition to {{$_POST.Items[0].Amount1.toNumber() +12}}
  2. If Items[0].Amount1 is say 15, then Addition becomes 1512, not 27

I’m using the PHP server model. I have the feeling that I reported something similar a long while back and that it had been fixed, but I may be wrong.

Hope this helps with the fix,


I believe that it is intended for you to put parenthesis around math.

Thank you Ken. It’s good to know that.

The current behaviour is still undesirable, though, for two reasons:

  1. if my operation is a subtraction instead of an addition (i.e., use a 'minus" sign instead of a plus sign) and I put no parentheses, the value is correctly set to the difference between the two numbers.
  2. my beloved formatter (sorry for editorializing) does not allow me to put parentheses in the expression. This means that I need to know that this s/b the case and do it in the code editor later.

One could argue that the plus sign is overloaded and that its use as string concatenation takes precedence over its use as algebraic addition whereas the minus sign does not have that problem because it is not overloaded. To avoid getting into a debate over how a language should represent its many operations, I would suggest that Wappler puts a string concatenation function elsewhere, and not in the Operation menu.

This brings me once again to my old rant about the formatter, and the functions bundled under Operations. I already suggested enhancements to the Formatter here and more specifically in point 6 here, more than a year ago – but there has been no traction with any.

Thank you again,


I regularly have the same issue - the only way I’ve found to reliably solve it is to always use the toNumber formatter again (I see you used it on the original number). That, or I use setValue multiple times with number as the type.

Does it also concatenate when you use the toNumber() on the value? It is normal when one of the the values is a string that it does concatenate.

I think so.

Did some testing and for me it works fine. When the value is a string and you do not use the toNumber() formatter then it will concatenate and result in 1512. When using the toNumber() formatter to make sure both are number then it the result is 27 as expected.

I can reproduce the issue. In step 3, the value is different from step 2.

Applying toNumber() yields the same result.

i.toNumber() + 1




Seems that the data picker generates the expression incorrect. Instead of generating {{i + 1}} it generates {{i }}1. George will continue on this, when you edit the expression in code then it should work, I’ve tested it with Server Connect PHP.

Hello! Just wanna mention, that problem is still exist. (w 4.0.4)
Tested in formatter for POST variables at server actions in NodeJS.
toNumber() doesn’t helps.
Editing in code doesn’t helps either, because it instantly rewritten after Editor is closed.

This has not yet been fixed. We will fix it in the upcoming updates.

Got it, thanks!

This has been fixed in Wappler 4.0.6

This topic was automatically closed after 47 hours. New replies are no longer allowed.