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
- In your Locale workflow, locate the Flow Controls section.
- Drag and drop the List Iterator action into your workflow where you want the iteration to occur.
Step 2: Configure the List Iterator
- Click on the List Iterator node to open its configuration panel.
- 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
- A data variable from a previous node (e.g.,
Step 3: Define the Sub-Workflow
- Connect the output handle of the List Iterator to the first action of your sub-workflow.
- Add and configure the actions you want to perform for each item in the list.
- 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:
- Use a database query or API call to fetch the list of customer emails.
- Add the List Iterator and configure it to use the fetched list.
- 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..."
- To:
- The List Iterator will execute this sub-workflow for each customer in the list.
Best Practices
- Data Preparation: Ensure your list data is properly formatted before using the List Iterator.
- Error Handling: Consider adding error handling within your sub-workflow to manage potential issues with individual items.
- Performance: Be mindful of the size of your list. For very large lists, consider implementing pagination or batching strategies.
- 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.