Forums

Saving the sum of values inside an event loop

bensonley 22 Feb, 2018
Having difficultly finding the right approach to calculate some values upon saving.

I have 3 tables that update or create new records on submit.


1 ( Service data) + 2 ( Pricing data) An Loop event (LE) that saves data in a repeater area in the form. Some custom php and read data actions inside the LE which looks up a third and small table to match the service type with a cost and add that cost to the service data when saving.

3 ( Assignee data) is the main one and final action. All normal {data:} fields are saved here, some custom php code in there to check and reformat dates. All fine. Except for what i want to add below:

What I want to do is add the LE values together to create a total value and add it to the Assignee table.
Not sure where to put the php to grab the LE values and add them together. I would like to create a string and use something like sum($values), but nothign ve tried has worked yet.

LE values i want are {var:loop_event45.cost}

If you need more data / info, let me know.

Ben
bensonley 23 Feb, 2018
Managed to solve it using a php foreach() loop prior to the LE. Dont know why i didnt think fo that before.
This topic is locked and no more replies can be posted.