Adding a number to a 'set value' in SC appends it rather than adding to its value

Wappler: 4.6.4
OS: MacOS
Server Model: PHP

I have some ‘set value’ actions in my Server Connect and am trying to increment one but it’s appending it instead. I have it set as a number and not text and also tried surrounding it with brackets but this is happening:

If var = 12, var + 1 should = 13 but it’s setting it to 121.

I’ve spent ages trying to get it to work but without any success. I’ve tried editing the SC in code view and formatting it there, too.

Just tested that on a PHP site, but the result is as expected:

results in:
Screenshot 2022-03-15 at 10.55.22

Thanks @Teodor. I’m sure it’s been fine previously for me so I’m very puzzled.

What about if the new value has the same name, eg. Set Value test = {{test + 1}}. That’s what I’m doing which is causing it to append.

FRom the screen pic, it looks like the variable is being defined as Text, not number, that would explain it

No, that screen pic is from @Teodor and his is working so it looks like the Data Type is irrelevant anyway? Mine are set to number already anyway.

The type option for the variable is only to tell the data picker what type of data to expect. It doesn’t change the type of the variable.
The type of the variable is automatically set depending on the data entered.

1 Like

Could this be the issue?

I just tested with the same variable name but it still works as expected:

Screenshot 2022-03-15 at 11.44.59

Likewise, checked and working as it should

1 Like

The only other thing slightly different with mine is I’ve also set the Global Name to be the same as Name because I’m using this in a few places in the whole script (within a While loop and outside it). Could that be part of the issue?

made no difference in my test

1 Like

Yes, works fine for me as well.
Can you just test it in a new empty server action and add steps one by one to see which one is causing it?

Hmm. I guess this is a good thing. I’ve just created a new server action and it’s working as it should.

@Teodor, can I send you my main script file to try and find what’s causing this?

Maybe post a screenshot of the steps here so we can check it.

OK, before I do that, this is what the UI shows:

Is that right? I can’t see that part in either of your screenshots.

Yes, the code looks correct.

Here’s a screenshot of the steps:

It’s a PayPal IPN script.

What field type in your DB is yNextWalkerNumber
image

I suspect this is being returned as a string.

You could try:
queryYear.yNextWalkerNumber.toNumber()

2 Likes

Thanks Ben. It’s an INT(6) field so should be a number. I’ve added the toNumber() as you suggested and will see what happens the next time the IPN runs. I have a feeling you could be onto something there.

1 Like

That fixed it. For whatever reason, the reading of the INT value was storing it as a string. Adding toNumber() to it has sorted it.

Thanks everyone.

1 Like