ForEach Control Step

The ForEach Control step is used to view or manipulate each element in an array which is in a record.

Praise Magidi avatar
Written by Praise Magidi
Updated over a week ago

The ForEach step iterates over the record array to process each element in the array.

When testing, the steps in the ForEach sub-flow will show only that 1 record has passed to emphasize that it reads one element at a time from the array. When executing, it will show the total number of elements that are in the array.

Illustrated in the below image is an example of a flow of how the ForEach Control step is used.

The Record Generator is used as a source step to populate data and an array is included in the record as shown in the image below.

The below image is the output of the data that is in the Record Generator.

Adding the ForEach Control step

To add a ForEach Control step in a flow, follow the below instructions:

1. Click on the highlighted icon as shown in the below image.

2. The below page will appear. Select or search for a Control step. Click on the Control tab and select ForEach as shown in the image below.

Configuring a ForEach Control step

Provide a title and description (optional). Once saved, open the control step to access more configuration options as shown in the image below.

The Swap Control Step is used to swap to another Control step. The ForEach Control step can only be swapped with the SubFlow Control step.

Using the ForEach Control Step

The ForEach step is added to a flow to process each element in the array. To add the array name in the ForEach step, click on the highlighted icon in the below image.

The below page will appear. The Array Path is the name of the array that is in the record. In this example, “tasks” is the array in the record. The Break on Error checkbox will break on any errors in the ForEach Control step sub-flow.

Illustrated in the below image is the output in the ForEach sub-flow. It breaks up each element in the array to process it by becoming separate records.

The output outside of the ForEach sub-flow is the original record as shown in the below image.

Additional information

Return

The options below let you define how you want the data to be returned from the Sub-flow. To access Returns, click on the Return button as shown illustrated in the image below.

Return Type

Select the option type you want the Sub-flow value to be returned as one of the following:

  • None - No return. This is equivalent to void in traditional programming.

  • Current - The default of the subflow being called.

  • Array - Converts the output to an array.

  • Object - Converts the output to an object.

  • String - Converts the output to a string.

  • Binary - Converts the output to a binary representation.

  • Base64 - Converts the output to base64.

Return Source

Selects what value types to return from the flow you are calling.

  • Auto - Auto detects the appropriate output.

  • Record - Returns the current record processed by the subflow.

  • Output - Returns the output of the Writer Step (if any) in the subflow.

  • Result - Returns the output of the Destination Step (if any) in the subflow.

Did this answer your question?