Forum Discussion
RogerDartnell
5 years agoQrew Trainee
Jessica,
I have not tried to do this exact variable (increment by 1) but you may be able to use the 'loop.index' variable to add the increment in each loop as this will increment by 1 each time through. I'm not sure if the syntax is correct but you could try something like {% set Variable = {"value" : "[your variable] + loop.index"} %} inside the 'for' loop. Then to user the variable is just {{Variable.value}}... I have used similar to set a field from an outer loop as a variable that can then be used in each inner loop to get child data for each parent record in a single request body.
Cheers,
------------------------------
Roger Dartnell
------------------------------
I have not tried to do this exact variable (increment by 1) but you may be able to use the 'loop.index' variable to add the increment in each loop as this will increment by 1 each time through. I'm not sure if the syntax is correct but you could try something like {% set Variable = {"value" : "[your variable] + loop.index"} %} inside the 'for' loop. Then to user the variable is just {{Variable.value}}... I have used similar to set a field from an outer loop as a variable that can then be used in each inner loop to get child data for each parent record in a single request body.
Cheers,
------------------------------
Roger Dartnell
------------------------------
HannahWright3
3 years agoQrew Trainee
Hey Roger,
Do you know if it's possible to use this loop.index solution to create x number of child records based off of a numeric value on the trigger record?
Where would you add this {% set Variable = {"value" : "[your variable] + loop.index"} %} jinja in the pipeline? As a value that you're mapping in?
------------------------------
Hannah Wright
------------------------------
- JoelHickok3 years agoQrew Assistant Captain
Overall, the need for a Pipeline-scoped global variable would be obvious. I am trying to set a "running total" variable so I can tally a total for each loop and stop looping when my running total reaches a desired value.
I don't really want to do this by creating a special field in the table and updating that field within my loop, but I will if that's the only way I can figure out.