Looper

Looping over lists, dicts and arrays

Overview

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).

Actions

1. Iterate Over Loop

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:

List of contacts
[
  {"id": 123, "email": "john.doe@mail.com"},
  {"id": 456, "email": "peter.gragory@mail.com"},
  {"id": 789, "email": "richard.hednricks@mail.com"}
]

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}}

2. Iterate While Loop

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.

Example

Run while the index is smaller than 10:

index < 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.

Action Loop arrow

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.

Nested loops

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.

Run certain iteration

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.

Referencing Behavior

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.

Last updated