Use For Each Item to execute a sequence of child steps once for each item in a collection. During each iteration, the current item is available to the child steps as the Item step output.
Step Library: Flow Control > Loops
When to use this step
Use this step when you want to:
- process every item in a collection in sequence;
- use the current collection item in one or more child steps;
- stop processing before the next item when a Boolean variable becomes true.
Common examples include:
- processing every order line, uploaded file, or selected recipient;
- creating one record or notification for each collected item; or
- stopping the remaining work when an earlier item produces the required result.
Use Repeat a Number of Times instead when the child steps should run a known number of times without reading items from a collection.
Use Repeat While instead when repetition is controlled entirely by conditions rather than by the items in a collection.
Before you begin
Create or identify the collection that the step should process. For Each Item supports Text, Number, Boolean, Date, File, and Object Collections.
If you want the loop to stop early, create or identify a Boolean variable that the workflow can evaluate before each new iteration.
This step does not require a connection or special permissions.
Configure the step
- Add For Each Item from Flow Control > Loops.
- Select the step to open its configuration panel.
- In Collection, select the collection to process.
- Optional: In Stop when, select a Boolean variable.
- Add the steps that should execute for each item inside the loop.
- In the child steps, select Item when you need the current collection item.
- Save or publish the workflow.
Settings
| Setting | Required | Accepted values | Visible when | Description |
|---|---|---|---|---|
| Collection | Yes | Text, Number, Boolean, Date, File, or Object Collection variable | Always | Collection whose items the child steps process. There is no default value. Flowifier reads the current collection again before every new iteration, so changes made by child steps can affect which iterations remain. |
| Stop when | No | Boolean variable | Always | Stops the loop before the next iteration when the selected variable is true. Fixed Boolean values cannot be entered. The default is Not set; in that state, the collection and the iteration limit control when the loop completes. |
Data and outputs
Workflow variable effects
This step does not directly modify workflow variables.
Child steps inside the loop can modify workflow variables. These changes remain available during subsequent iterations and after the loop completes. If a child step changes the selected Collection, Flowifier uses the changed collection before the next iteration. For example, clearing the collection ends the loop before another iteration starts, while appending items can add further iterations up to the iteration limit.
If a child step changes the Boolean variable used by Stop when to true, the loop stops before starting the next iteration.
Step outputs
| Step output | Type | Available when | Scope | Description |
|---|---|---|---|---|
| Item | Text, Number, Boolean, Date, File, or Object | During an iteration that has a current item | Child steps inside the loop | Current item from Collection. Its type matches the collection item type. For an Object Collection, the output retains the collection's Object schema. It is replaced for each iteration. |
Item is available only to child steps inside the current iteration. It is removed when the iteration finishes and is not available to steps following the loop. An empty collection produces no Item output because no iteration starts.
Runtime behavior
Execution and completion
Before starting every new iteration, Flowifier performs the following checks in order:
- If Stop when is configured, Flowifier evaluates the selected Boolean variable.
- If the variable is
true, the loop completes without starting another iteration. - Flowifier reads the current value of Collection.
- If there is no item at the next collection position, the loop completes.
- If another iteration would exceed the limit of 1,000 iterations, the loop fails before iteration 1,001 starts.
- Flowifier exposes the current item as Item and executes the child steps sequentially.
After the child steps finish successfully, Flowifier removes Item and evaluates whether another iteration should start. When the loop completes, the workflow continues with the next step following the loop.
An empty collection runs no child steps. Because Flowifier reads the collection again before each new iteration, changes to the collection's length or items can affect the remaining iterations.
Branches and child steps
This step has one child branch. All steps placed in this branch execute once per iteration and in their configured order.
The branch does not execute when:
-
Stop when is
truebefore the first iteration; or - Collection is empty before the first iteration.
Workflow variable changes made by child steps are retained. The Item step output is limited to the child branch and the current iteration.
Failure, retry and resume behavior
This step does not automatically retry failed child steps.
If a child step fails, is cancelled, terminates the workflow, or ends the workflow, the loop propagates that result immediately. It does not execute later child steps, start another iteration, or continue with a step following the loop.
If a child step suspends the workflow, for example by waiting for a specified duration, the loop is suspended with it. When the workflow resumes, Flowifier continues the same iteration with the same Item value and does not replay child steps that already finished. Stop when and Collection are evaluated again before the following new iteration.
Errors and limits
| Situation | Result | Resolution |
|---|---|---|
| Collection is missing | The workflow cannot be published with a valid configuration. | Select a supported Collection variable. |
| Collection references a non-collection value | Designer validation rejects the incompatible value. | Select a Text, Number, Boolean, Date, File, or Object Collection variable. |
| Stop when references a non-Boolean value | Designer validation rejects the incompatible value. | Select a Boolean variable or leave Stop when as Not set. |
| Collection is empty | The loop completes without running its child steps. | Add items before the loop if at least one iteration is required. |
| A child step removes the remaining collection items | The loop completes when no item exists at the next collection position. | Ensure child steps change the collection only when that behavior is intended. |
| Another iteration would exceed 1,000 iterations | The step fails before starting iteration 1,001. | Reduce the collection size or prevent child steps from continually adding items to the collection. |
| A child step fails | The loop stops and propagates the failure without an automatic retry. | Inspect the failed child step in the workflow instance log, correct the cause, and start a new workflow instance. |
| A child step cancels, terminates, or ends the workflow | The loop stops immediately and propagates that result. | Review the child step that caused the cancellation, termination, or early completion. |
The iteration limit applies to the number of iterations actually started. The loop can successfully complete up to 1,000 iterations.
Example
Log every order number in a collection
Goal: Write one instance-log entry for each Number in an orders collection.
Configuration:
-
Collection: Number Collection
orderNumberswith the value[101, 102, 103] -
Stop when:
Not set - Child step: Log to Instance Log using Item in the message
Result: The child step runs three times in collection order and can create messages equivalent to:
Processing order 101 Processing order 102 Processing order 103
After the third iteration completes, the workflow continues with the next step following the loop. Item is no longer available outside the loop.
Related information
- Repeat a Number of Times — repeat child steps a fixed number of times.
- Repeat While — repeat child steps while conditions remain true.
- Group Steps — organize multiple child steps without repeating them.
- Workflow variables — store collections, stop conditions, and values changed by child steps.
Comments
0 comments
Please sign in to leave a comment.