Learn about the built-in Iterator Tool available in Flows.
This article covers the following topics:
- What is the Flows Iterator Tool and what does it do?
- What challenges does the Iterator tool address?
- How to Access and Apply the Iterator Tool to Your Flows
What is the Flows Iterator Tool and what does it do?
Before delving into the tool and how it works, let's start with understanding some foundational information.
In Flows, Rows represent an unlimited set of data associated with a specific entity. For instance, consider a "Deal" within a CRM system that encompasses various items for sale:
Each "Deal" can include a range of goods, and every item possesses distinct attributes such as name, quantity, and additional relevant information. All these attributes are organized within a single array.
Example JSON "Deal" object:
{
"dealName": "Deal 1",
"items": [
{
"name": "Good 1",
"quantity": "2"
},
{
"name": "Good 2",
"quantity": "5"
}
]
}
Each item within the array is referred to as a Row, while the complete set of these items collectively are called Rows.
In Flows, the Iterator Tool is designed to handle each element of an array individually. This functionality ensures that any subsequent steps in the Flow will execute a corresponding number of times, based on the number of elements present in the array.
Note: The Iterator Tool is commonly used after Search for Multiple Records actions.
What challenges does the Iterator tool address?
Let's say you have a Knack app that stores customer orders, and you want to automate the process of sending order confirmations to customers. Each order might contain multiple items, and you want to ensure each item is included in the confirmation email.
Example using the Iterator Tool:
-
Trigger: The Flow is triggered when a new order is created in Knack.
-
Retrieve Order Data: Flows pull the order details, which include a list of items (an array of products in the order).
-
Iterator Tool: This is where the tool comes in. You would use the iterator to loop through each item in the array, processing each one individually. For example:
- Extract product name, quantity, and price for each item
- Format the details for inclusion in the email
-
Action: After iterating through all items, Flows can send a confirmation email to the customer that includes all the products in their order, with itemized details.
-
Further Actions (Optional): You could also use the Iterator tool to trigger additional steps, such as updating inventory levels in Knack for each product or sending notifications to a warehouse.
How to Access and Apply the Iterator Tool to Your Flows
After selecting the Flow where you want to utilize the Iterator Tool, identify the specific steps within the Flow that require the application of your desired conditions.
You can then add a Tool by clicking on the "+" button underneath each necessary step. Clicking the "Tool" option will allow you to select from a range of different tools Flows offers, including the Iterator Tool.