For Each

The For Each tool allows each item in a collection to be processed one by one. This is essential for batch operations in which multiple items require similar handling.

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

Consider the integration of an E-commerce platform with a CRM. For each customer who makes a purchase on the platform, you want to:

  • Add the customer’s data to the CRM.

  • Send a welcome email.

In this integration, For Each handles multiple customers in a single order. It ensures that for each customer found in the order details, the subsequent actions (adding to the CRM and sending an email) are performed individually.

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

Add For Each to the canvas

  1. Click the wrench icon with a plus sign icon from the editing menu on the left.

  2. Select For Each to add it to the canvas. You can use the search bar search steps icon to find it.

  3. Drag to the For Each board the steps (except triggers) that will be iterated (repeated).

To remove steps from 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 the steps and leaves the For Each board empty. Select the For Each board and click the third button on the right.

To delete For Each from the canvas, select it and click the trash can icon button. All the steps within For Each will be deleted and the connections removed.

The alert icon alert icon on the For Each board will only disappear if there are:

  • At least one step within For Each;

  • The input connection, on the left;

  • The output connection, on the right.

alert for each

Configure the form

  1. Select the For Each tool on the canvas.

  2. Click the pencil icon editing icon.

  3. Fill in the following fields:

    • Name: enter a unique name for the step For Each. This is an alphanumeric field that allows special characters and blank spaces, with a limit of 20 characters.

    • Variable List: list of variables that will be executed. The values must be an array (list). This is an alphanumeric field that allows special characters and blank spaces, with a limit of 1024 characters.

      By clicking the Properties icon list icon on the right, you can:
      a. Select previously registered variables.
      b. Create expressions using the Expression Builder.
    • Iteration Element: name of the structure that identifies the elements inside For Each. This is an alphanumeric field that allows special characters and blank spaces, with a limit of 250 characters.

      You can see the name registered in Properties or in the Data Mapping (FROM/TO) of the steps that are within For Each.
      The amount of repetitions is determined by the amount of items in the array (list).
  4. Configure the Ignore Errors button: by default, the button is disabled and you can enable it.

    Enabled switch Disabled switch off

    Execution continues, even if there are errors in the process.

    Execution will be stopped immediately.

    The logs show the step with an error.

    The logs show the execution up to the last iteration.

    Steps after For Each will be executed.

    No step after For Each will be executed.

  5. Click SAVE.

for each form

For Each within For Each

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

Consider the integration between an E-commerce platform and an inventory management system. Each order contains multiple items and, for each item, you need to update the stock levels.

  • Order 1: Item 1, Item 2, Item 3.

  • Order 2: Item 1, Item 2.

  • Order 3: Item 1, Item 2, …​, Item 10.

  • The outer For Each is responsible for iterating through each order, ensuring that each order is processed one at a time.

  • The inner For Each operates within the context of a single order, iterating through each item in that order to perform necessary operations, such as updating stock levels.

This would be a visual representation of this integration:

diagram for each ext int en
To move a step between two For Each boards, you must detach it from the initial For Each. To do that, click X and drag it to the new For Each.

Ignoring errors

When a flow has a For Each within 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 if there is an error.

Enabled

Enabled

The flow will NOT be interrupted if there is an error.

Enabled

Disabled

The entire outer For Each iteration will be executed.

Disabled

Enabled

The flow will NOT be interrupted if there is an error.

Expression Builder

The Expression Builder component allows you to create expressions with parameters and variables through functions and conditions available within the component. This allows you to adjust the expressions to meet your needs.

Follow the steps below to access the Expression Builder screen:

  1. Click the Properties icon list icon, to the right of the Variable List field.

  2. Next, click the expression icon icon in the upper-right corner.

expression builder for each

The Expression Builder screen contains the following sections:

  • Properties: shows data from previous steps and from the environment variables. Filter the attributes using the search field at the top of the section and then click the magnifying glass icon. You can select more than one attribute. When selecting it, the attribute will appear in the Expression field.

  • Expression: field to enter the input attributes or to create an expression by clicking the fx button button on the right. Only the Concat function is available to create the expression.

When selecting two or more attributes in the Properties field, you must create an expression.

To save the information, click CONFIRM.

Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]