List Iterator / Loop

Introduction

The List Iterator is a powerful flow control tool in Locale that allows users to execute a sub-workflow for each item in a list. This feature is particularly useful when you need to perform repetitive actions on a collection of data, enabling more dynamic and flexible workflow designs.

Overview

Located under the Flow Controls section in Locale, the List Iterator provides a way to loop through arrays or lists of data. For each item in the list, it executes a defined sub-workflow, passing the current item's data into that sub-flow.

Key Features

  • Iterate over arrays or lists of data
  • Execute a custom sub-workflow for each item
  • Pass individual item data to the sub-workflow
  • Flexible integration with other Locale actions and apps

How to Use the List Iterator

Step 1: Add the List Iterator to Your Workflow

  1. In your Locale workflow, locate the Flow Controls section.
  2. Drag and drop the List Iterator action into your workflow where you want the iteration to occur.

Step 2: Configure the List Iterator

  1. Click on the List Iterator node to open its configuration panel.
  2. Specify the data source for your list. This could be:
    • A data variable from a previous node (e.g., {{ previousNode.data.items }})
    • The result of a database query or API call

Step 3: Define the Sub-Workflow

  1. Connect the output handle of the List Iterator to the first action of your sub-workflow.
  2. Add and configure the actions you want to perform for each item in the list.
  3. Use the {{ item }} variable to access the current item's data within the sub-workflow.

Example Use Case

Let's say you have a list of customer emails and you want to send a personalized message to each one:

  1. Use a database query or API call to fetch the list of customer emails.
  2. Add the List Iterator and configure it to use the fetched list.
  3. In the sub-workflow:
    • Add an "Send Email" action.
    • Configure the email with:
      • To: {{ tool.data.email }}
      • Subject: "Special offer for "
      • Body: "Hello , we have a special offer for you..."
  4. The List Iterator will execute this sub-workflow for each customer in the list.

Best Practices

  1. Data Preparation: Ensure your list data is properly formatted before using the List Iterator.
  2. Error Handling: Consider adding error handling within your sub-workflow to manage potential issues with individual items.
  3. Performance: Be mindful of the size of your list. For very large lists, consider implementing pagination or batching strategies.
  4. Testing: Thoroughly test your workflow with different list sizes and data types to ensure it behaves as expected.

Limitations

  • The List Iterator processes items sequentially. For parallel processing of large datasets, you may need to explore other solutions.
  • The performance of the List Iterator depends on the complexity of the sub-workflow and the size of the list.

The List Iterator is a versatile tool in Locale that enables users to create more dynamic and data-driven workflows. By allowing the execution of sub-workflows for each item in a list, it opens up possibilities for batch processing, personalized actions, and complex data manipulations within your automation processes.