Going insane - how to simply add two values together in a SC - bug?

Hey all,

I’m not sure if this is a bug, but I’ve tried every permutation of formatters I can think of.

I’m trying to add say 400 and 100. Instead of getting 500 I’m getting 400,100.

Latest formatter in SC:

{{checkcredits.contact_credits_month_use.toNumber() + $_GET.records_number}}

I’ve tried without the .toNumber()
I’ve tried with the .toNumber() at the end.

I’ve tried encasing everything in brackets, so:
{{(checkcredits.contact_credits_month_use.toNumber() + $_GET.records_number)}}

I’ve even tried using setValue with the type output as number on the first value, another on the second value, and then a third adding these together in setValue to see if it was an issue within the DB Query Manager. No luck.

When I build the action, it initially looks like this, that it is combined:

Screen Shot 2020-12-22 at 10.06.12 am

But when I then go back into the action after saving it, it’s suddenly split:
Screen Shot 2020-12-22 at 10.07.16 am

And turns into this code:
checkcredits.contact_credits_month_use +records_number.toNumber()

Can anyone check this is working on their end, noting this is in SC not AC. I use NodeJS, too.

No problem here:

Hi Ben, thanks for jumping in - did you use he exact same expression? And did you do this purely SC, not AC?

E.g. I created a setVal with the output to see what it looks like in the console?

Sorry, the example is AC.

Tried SC and still works

Try a little workaround. Instead of assigning a fixed value as I have done, supply the dynamic value and see how you go.

I was assigning dynamic values, this is where it hasn’t been working for me. Let me try again i’ll just recreate your static example, instead of dynamic and see if that works.

out of curiosity - is there a chance that when displaying the SC on the F/E - it’s rendering the value correctly, but it doesn’t on the Server side? I’m not displaying this ever on the FE it’s all for SC actions…

@ben

So I recreated your example, 2 static setValue numbers + a setValue adding those two together. They outputted the right number.

Then, when I try to use my two dynamic values, it fails again.

Screen Shot 2020-12-22 at 1.45.55 pm

a + b = c (500) - correct.
records + credits values = two numbers ajoined, instead of combined to a total.

I’m assuming there is a bug with dynamic values? Would you mind seeing if this is working on your end?

Sorry mate, a very busy time of the year. I am assuming that either one or both of the dynamic values need to be changed to numeric. Pay particular attention to the $_GET value as this is usually a string value.

Was going to suggest a similar thing. Maybe try playing with the .toNumber() formatter a bit more. Add it to left or right or both or none.

Thank you both, got it!

Seems overkill but I did the following to get it working:

Convert the $_GET into a number value.
Then in the setValue for the $get value I format that to a number
Then in the second setValue step I get the value from the db and format that to a number
then the third setValue step I get the first setValue, convert to a number again then + the second setValue, convert to a number again and it worked…

Happy that it’s working, but must look at refining this a little. Thanks both again.

1 Like