Server Action Set Value - Unexpected Behaviour

So I’m digging into larger server side actions for the first time, and have come up against some strange behaviour.

I have a code structure like this:

Set Value amount = value1
if condition A then
     Set Value amount = value2
if condition B then
     Set Value amount = value3

Each Set Value command is set up to Output.

When condition A and condition B are false, amount is value1 as expected.

However, when condition A or condition B are true, amount is null, instead of value2 or value3.

Am I only allowed to assign to a value once?

It should be working just fine.
If the value is null, then the values you assign there in the conditions don’t return anything.

Okay, I’ve discovered what is going on, and my initial thoughts were a red herring (leading me the wrong way).

I’ve found that the formatNumber() function on the client side is sometimes returning null.

So I have these paragraphs on my page:

fff1

And here is the result when I run my app:

fff2

Here is the server action at the moment:

fff3

And to_pay_now was also assigned as a number.

Then check the browser console for errors and you will see the reason for this, explained there.

Yes, thank you Teodor… I had just thought of what it may be while making a cup of tea, and the browser console has confirmed it… the assignment of amount_to_pay_now needed converting to a number.

That fixed it.

There is soooo much to learn! :confounded: