Looper
Looping over lists, dicts and arrays
Last updated
Looping over lists, dicts and arrays
Last updated
The Loop Helper is one of the most powerful Helpers and at the same time, one of the easiest to setup. It allows you to loop over lists, a list of dictionaries and arrays and execute an action multiple times (each entry of the list, dict or array).
The Iterate Over action loops over a pre-defined list.
Let's use an example: Imagine you want to send emails to each user you get from the Get Contacts step that returns a list of contacts:
Select the Action type Iterate Over and input get_contacts
to the Loop Reference. In the Action Loop send an email to each user by accessing the email property with the Jinja expression {{get_contacts[index].email}}
The Iterate Over action loops while (until) a defined condition is matched; usually e.g. until there are no more pages to loop over.
The condition is always checked at the end of each loop iteration so that you can also reference steps that happen inside the loop, which are not yet available at the beginning of the first iteration.
Run while the index is smaller than 10:
This loop will have 11 iterations because index
starts at 0
and the condition is checked at the end and not at the beginning of each loop iteration.
The iterate while loop has a maximum of 1000 iterations for capacity protection. If you need to increase this limit, please raise a support ticket.
It is necessary to link the ActionLoop arrow in the Looper Helper to the steps that will be executed during each iteration.
The Looper Helper is associated with the pre-created arrow named ActionLoop, so don't change it or it will break.
It is possible to loop over multiple objects, e.g. over a list of companies (loo1
) then over each employee (loo2
) then over each ticket of an employee (loo3
). Just make sure, you reference correctly in the subsequent branches of the loop.
Keep in mind that {{index}}
always refers to the current loop. In a nested loop, {{index}}
will always reflect the index of the innermost loop. If you need to reference the index of an outer loop, you must store that index explicitly in a variable (using a "Dict Helper" step or a similar approach) before entering the inner loop. This allows you to safely access the outer loop's index while iterating through the inner loops.
The Looper runs all iterations by default, but if working with complex flows and if waiting for results is time- or resource-consuming, you can also run a selected iteration, when using Single Flow Step runs.
When running the entire Flow, the Looper will run all iterations, no matter what iteration index is set.
Using the same reference inside a Looper as the Looper Helper itself does not work as expected, as the Looper Helper's reference will always have priority, while the Looper is running, and thus any other step with the same reference inside the loop will never be considered.
The "Run Iterations in Parallel" feature is designed to accelerate flow execution by processing items in batches of 10 concurrently. After completing the first batch, the Looper moves on to the next batch of 10 items (or the remaining number).
Key Aspects of the Parallel Looper:
Sorting:
The output in the step's debugger will be sorted by start date, so steps from later iterations might appear before those from earlier iterations.
Currently in development: Sorting of the final output of the Looper according to the iteration indexes and then start date (so that different iterations are not mixed in the Flow Debugger)
Each step in the Looper can have its own error handling:
Terminate flow: If a step fails with this error handler, no further iterations will be scheduled. However, already scheduled iterations will continue to execute.
Skip loop iteration: This error handler skips the current iteration but allows the Looper to continue processing other iterations.
Break current loop: This causes the Looper to exit the current loop iteration but does not affect others.
If multiple errors occur with different handlers, the most severe one dictates the outcome:
For example, if multiple steps fail and use different error handlers (e.g., one step uses Skip loop iteration, another uses Break current loop, and a third uses Terminate flow), the "worst" status wins. In this case, the Looper will terminate with an error, and flow execution will not continue.
Completion of Running Iterations:
If an error occurs that requires stopping further iterations (like "Terminate"), the Looper will not schedule any more batches.
However, all currently running iterations will be allowed to complete. For example: if an error happens on the 3d iteration, the Looper will finish the remaining iterations from the current batch