For Each in a List

Use the For Each in a List step when you need to repeat a set of actions on a collection of items.

In this flow step, you define the collection of data. Then in your flow, nested under the For Each step, you add child flow steps that define the actions you want to perform on this collection.

Tip: You can use the helper code flow.loopItem() in a child step to reference a specific item in the collection. This may be helpful for targeting list items with specific features.

On the App Xchange platform, the For Each step processes all items at the same time, but the output of each iteration will be in the same order as the input.

Step Inputs

In the Edit Step menu, you can add details about the step configuration as needed for your flow.

Note: For Each loops cannot see any steps outside the For Each loop. The best practice is to pass the data in a part of the For Each loop input.

Step Detail

List

Define the collection of data.

Example value:

This value identifies data that is coming from a set of budget items created by a previous flow step.

Wait for all action responses

This option is off by default. Toggle this option on if you want each child flow to run and complete associated actions before moving on to the next flow step.

Step Status

You may see one of the following statuses after running the For Each in a List step:

SUCCESSFUL

Occurs when the For Each step executes successfully.

SUSPEND

Occurs when:

FAILED

Occurs when there is a code exception that prevents the For Each step from executing.

Step Outputs

The output of the For Each step is the processed collection of data. In most cases, this means some sort of action has been taken on the dataset, and child Stop steps indicate success or failure of these actions.  

Use Case and Example

For example, say you take the output from a previous step, which filters Vista records to sort out those with missing or mismatched job phases. Then you add a For Each step to pass each Vista record to a child flow that adds Vista job phase data (using a Connector Action step). Stop Flow steps indicate if the job phase was added successfully or if the action failed.

In this scenario, the For Each in a List might have this setup:

This is how the For Each step might look with its substeps:

This means, for each job phase you add to Vista from ProjectSight, the flow will do the following: