Loop
The Loop stage allows you to loop over a collection of data items and carry out an action on those items. For example a list of userIDs and you want to perform an action per user in the list or get a certain piece of data per user to check.
Field | Description |
Items to loop on | The name of the collection to iterate over |
Loop item name | The variable name to use for each item in the collection. This name can then be used within the loop path to carry out actions on |
Examples
If the collection is s simple list such as: ["Robert","John", "Bob"]
and the 'Loop item name" is set to name
then the stage will loop 3 times and on set "name" to Robert then John and then Bob in each iteration.
If the collection is an associative array such as a userlist with information per user:
[
{"name": "Robert", "age": "32},
{"name":"John", "age": "27"}
]
And the name set as "Loop item name" is user
then you can use dot notation to reference one of the data elements within the userlist array (e.g. user.name
or user.age
). See example stage below:
Outputs
The stage has 3 output points:
The path at the bottom of the stage will be followed in a loop for each element in the collection (per user in our example above)
Once all iterations are complete, the stage will flow out of the green path. If there was an error during processing then the red path is followed