For Each

Use the For Each activity to create a loop that runs once for each item in a source array. For Each loops are one of the two types of loops available in Automation. This type of loop consumes an array of data and runs the content of the loop a single time for each item in the array. If you want to loop for an arbitrary number of times or while a condition is true, see the While Loop Help topic.

Note:
  • When naming the For Each activity, always specify the entity name which will be used in a loop (example: expand For Each to For each indicator)

  • You can stop a loop using the Break activity.

  • You can skip the rest of a single iteration of a loop or continue after a failure using the Continue activity.

Source Data

The source data for a For Each loop must be an array. This often comes from activities such as Read Table from JSON/Text/XML or Split String. To provide the source data for the loop, you must choose the array variable.

Source Data

Column Variables

Within the For Each loop, you may want to use the values in the table columns. You can do this by using the variable browser to choose the Loop, Source Array, Items, and Column you want to use. Here is an example where the name column is used as a variable:

Column Variables

Usage

Complete the following properties to use this activity:

  • Source Array - Click the Variable Reference icon to choose a variable.

Sample Workflows

The following sample workflows are available in our repository’s workflows folder to help you get familiar with this concept. These can be imported using the instructions in Import Git Content or you can click the workflow to view it in GitHub.