---
title: For Each
description: Learn about For Each
documentId: ipaas-legacy-for-each
locale: en-US
---

The **For Each** tool allows you to process each item in a collection, one at a time.
This is important for batch operations where multiple items need similar handling.

Automating the processing of multiple items reduces manual intervention, thus increasing efficiency and consistency in data processing.

>Imagine you have an *E-commerce* platform that receives customer orders. 
>Each order can have multiple items (products) and, after purchase, each order item needs to be processed individually to perform actions such as checking inventory, calculating taxes, and generating a consolidated invoice, for example.
>
>In this case, you could use a **For Each** to iterate over the order items and perform a series of actions for each of these items independently.

See what the flow described above would look like:

![](https://creative-ball-51b3fc85c0.media.strapiapp.com/for_each_new_order_example_f00e27c3e6.png)

Next, learn how to add **For Each** to the canvas and how to configure its form.

## Add For Each to the canvas

<Steps>
<Step>
Click the ![tool icon with plus sign](https://creative-ball-51b3fc85c0.media.strapiapp.com/general_Tools_Icon_43cb976f10.png) icon in the left editing menu.
</Step>
<Step>
Select **For Each** to add it to the canvas.
You can use the search bar ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/search_steps_icon_245a7221ea.png) to find it.
</Step>
<Step>
Drag into the **For Each** box the *steps* (except trigger) that will be iterated (repeated).
</Step>
</Steps>

To remove *steps* from inside **For Each** without deleting them from the canvas, there are two buttons:  

* **Detach**: detaches a single *step*. 
Select the *step* you want to detach and click the third button on the right. 

* **Ungroup**: ungroups all *steps* and leaves the **For Each** box empty. 
Select the **For Each** box and click the third button on the right. 

To delete **For Each** from the canvas, select it and click the ![trash icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/remove_Icon_486c52eeeb.png) button. 
All *steps* inside **For Each** will be deleted and connections will be removed.

<Callout type="note" title="NOTE">
You can only have one subflow inside the For Each *step*, that is, **it is not possible to execute parallel subflows inside For Each**. 
If there are inactive *steps*, you will see a yellow alert icon ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/yellow_alert_icon_6d196bf914.png) on the *step*, informing that it is inactive and requires a connection to be executed.
</Callout>

---
The alert icon ![alert icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/alert_Icon_86fad7682f.png) on the **For Each** box only disappears if there is:

* At least one *step* inside **For Each**;
* The input connection on the left;
* The output connection on the right.

![for each alert](https://creative-ball-51b3fc85c0.media.strapiapp.com/for_each_alert_1ecb9b8e9c.gif)
---

## Configure the form

<Steps>
<Step>
Select **For Each** on the canvas.
</Step>
<Step>
Click the edit icon ![pencil icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/edit_icon_34464736ca.png).
</Step>
<Step>
Fill in the following form fields:
* **Name**: enter a unique name for **For Each**.
This is an alphanumeric field that allows special characters and empty spaces, with a limit of 20 characters.
* **Variable List**: enter the list of variables to be executed, that is, the list that contains the items that should be executed individually.
Values must be an *array* (list).
This is an alphanumeric field that allows special characters and empty spaces, with a limit of 1024 characters.

---
By clicking the **Properties** icon ![list icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/properties_icon_2c777edb35.png) on the right, you can:

1. Select previously registered variables. 
2. Select input or output *payloads* from previous *steps*.
3. Create expressions using the Expression Builder.

<Callout type="note" title="NOTE">
Read more about [**Properties and Expression Builder**](/docs/integrations/ipaas-legacy-expression-builder).
</Callout>
---

Below, we demonstrate the selection of a list (*array*) of items (from **Properties** ![list icon](https://creative-ball-51b3fc85c0.media.strapiapp.com/properties_icon_2c777edb35.png)) that will be processed by the For Each tool.

---
![](https://creative-ball-51b3fc85c0.media.strapiapp.com/for_each_select_variable_list_68fef6007f.gif)
---

* **Iteration Element**: name of the structure that identifies the elements that will be repeated inside **For Each**. 
This is an alphanumeric field that allows special characters and empty spaces, with a limit of 250 characters.

<Callout type="tip" title="TIP">
You can view the name of the element to be iterated in **Properties** or in the **Data Mapping (FROM/TO)** of *steps* that are inside **For Each**.
</Callout>

<Callout type="note" title="NOTE">
The number of iterations is determined by the number of items in the *array* (list).
</Callout>
</Step>
<Step>
Configure the **Ignore Errors** button: by default, the button is disabled and you can enable it.

| Enabled ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/switch_b7a9c56956.png) | Disabled ![](https://creative-ball-51b3fc85c0.media.strapiapp.com/switch_off_460667d32c.png) |
|---|---|
| Execution continues, even if there are errors in the process. | Execution will be stopped immediately. |
| *Logs* show the *step* with error. | *Logs* show execution up to the last iteration. |
| *Steps* after **For Each** will be executed. | No *step* after **For Each** will be executed. |
</Step>
<Step>
Click **SAVE**.
</Step>
</Steps>

![for each form](https://creative-ball-51b3fc85c0.media.strapiapp.com/for_Each_Screen_7bd5b6ae10.png)

<Callout type="note" title="NOTE">
See an example of [integration with CRM and For Each](/docs/integrations/ipaas-legacy-example).
</Callout>

### For Each inside another For Each

You can insert a **For Each** inside another **For Each**. 
This way, your integration flow will process data in structures with nested *loops*. 


>Consider the previous example of a flow with an order that contains multiple items (products). 
>Imagine that each item is subject to the payment of two taxes.
>
>* **The outer For Each** iterates over the list of items.
>* **The inner For Each** iterates over the list of taxes for each item.
>
>This way we have a list (*array*) inside another list:
>
>* New order:
>
>  * Item 1
>    * Tax 1
>    * Tax 2
>  * Item 2
>    * Tax 1
>    * Tax 2
>  * Item 3
>  * Item 4

The described flow would look like this:

![](https://creative-ball-51b3fc85c0.media.strapiapp.com/for_each_within_for_each_7c4d9a749a.png)

<Callout type="note" title="NOTE">
To move a *step* between two **For Each** boxes, you must detach it from the initial **For Each**. 
To do this, click **X** and drag it to the new **For Each**.
</Callout>

#### Ignoring errors

When a flow has a **For Each** inside a **For Each**, the following rules apply to the **Ignore Errors** button:

| "Ignore Errors" in outer For Each | "Ignore Errors" in inner For Each | Result |
|---|---|---|
| Disabled | Disabled | The flow will be interrupted when an error occurs. |
| Enabled | Enabled | The flow will NOT be interrupted when an error occurs. |
| Enabled | Disabled | The entire iteration of the outer For Each will be executed. |
| Disabled | Enabled | The flow will NOT be interrupted when an error occurs. |
