How to trigger event of a changed value in a repeated container list

Hi,

I have a list of repeated container where the user will have to input the sales amount

I would like for the system to immediately calculate the respective repeated container’s commission amount, but still at the same time allowing the user to edit it if needed

In a non-repeated container, this can easily be done by using the page variable trigger event. However, in a repeated list, it cannot be done as there is no ‘trigger event’ for any change in the respected repeated list

I’ve tried making my own trigger event from the input container. However, the system takes the ‘old’ value for the formula, not the ‘changed’ one. However, I’m not sure that issue is due to the trigger event issue, or the installed logic ‘set repeated item value’

Please help, thank you

From your question I imagine that you want to do a calculation like:

salesTotal[i] = pricePerUnit[i] * numberOfUnits[i]

To do it in a repeated container, you can build an array with a schema like:

array = [{salesTotal : 0, pricePerUnit : 5, numberOfUnits : 0}, {…}, {…} ]

For such calculations, there is no trigger required. Instead you an calculate the value for ‘salesTotal’ with a formula in each repeated container using the ‘value in repeat’.

Edit: Well, to save the result of the calculation to a variable (e.g. salesTotal[i]) you might need a trigger. Such trigger event could be a button (onClick) inside the repeated container.

Hi,

Thank you for your suggestion. Really appreciate it.

If I understand correctly, do you mean to put the salesTotal as a fixed formula resulting from the other two variables?

I can do it that way if I want the formula to be fixed. But there are times that the amount is not based on a formula. So I would like to make it automatically change if I adjust the other variable’s value, but still at the same time I am allowed to make manual adjustment

At the moment I’m using a button to calculate and set the salesTotal amount. Just that I wish there’s a way that it can reflect immediately once I typed the amount for the other variable’s.

ok, I understand you prefer a triggered event. Good to know, that it already works for an onClick event with a button in each container.

Can you share more details, what issue you are experiencing with the onChange event of the pageVariable?

There isn’t any specific issue. Just that from UX perspective, it is much more convenient that the system auto calculate immediately rather than having to press another button for it to calculate. I’m trying to make the system as user friendly as possible

Yes, I understand your goal.

My question would be:

  • what exactly is your setup regarding the onChange-event of your variable? How do you assign the individual variables to the repeated containers → share some screenshots please
  • what errors do you get? → please share some screenshots about it as well