Set values inside repeat / cannot sum them -> broker_earning }}{{broker_fee_num

Hello. I found days ago a tutorial from @Teodor teaching how to set a value and use it in the repeat to sum values from each record.

In the first api action I did, it work perfectly:

api_01:

Problems arrive at the second API action, where I cannot sum the values:

the api action is the following:

I set the Value on the first red frame. But when I go to make the sum in the repeat, it doesn’t sum but I got the following:

Schermata 2021-04-20 alle 19.03.16

I checked and all variables are “Number” not text. But it seems that I get a text as result:

What’s happened between the first api action and the second one? Just updated Wappler to latest version but I do not think it is something wappler-related.

Any suggestions ?
thank you

Roberto

The set value should be

broker_earning+broker_fee_num

(not {{broker_earning}}{{broker_fee_num}} )

As far as I know the Set Value step is relative to the section it’s placed in. Inside a repeat, each Set Value relates to that specific record of the resultant repeat array/loop.

i.e.

data:{
broker_earning: null (set by the first Set Value)
repeat:[
{
broker_earning: "500" // can't access the first broker_earning to add)
},
{
broker_earning: "500" // can't access the first broker_earning or one from first record
}
]
}

You could initialise a session value to null and set that at each step so that it was available at all levels

Hi,
I know it is not correct way.

I just opened the api action file in the editor and I put the + between the two variables and works fine.

Just wonder why through UI get this result

Edit the expression in Code view


You can type it in

Ah. Seems the picker overrides it and breaks the expression - one for @george I reckon!

Was already reported, will be fixed in the next update.

3 Likes

Hi @George,

I didn’t use the “BUG template” because I was believing I was doing something wrong!

This has been fixed in Wappler 3.9.6