Here's a step by step guide about the Iterator module in FlowMattic. Iterator module help you loop through the array data and execute the steps following the Iterator.
1. Create a new Workflow
Start with creating a new workflow. Learn more about creating a workflow in FlowMattic.
2. Capture data with JSON array
Capture data in workflow trigger or retrieve it from another source using the API module etc. We will us the WooCommerce new order trigger for this article as an example. The captured data as JSON array will look like in the screenshot below ( Line Items ) -
3. Using Iterator Module
Now, add new action step and choose the Iterator module. You can find the Iterator module at the top of the list in the available apps when you open the choose application dropdown.
4. Configure Iterator
Lets configure the Iterator.
- Choose the action as Loop Through Array.
- In the field for Iteration Array, choose the dynamic field from the data captured in the previous step. We will use the Line Items data from the WooCommerce trigger as seen above.
- Once all the fields are configured, click the Save & Test Action button.
- You will get a single item from the number of array items that you can map within the next action steps.
Here's how the Iterator step will look like when you configure it and test the action -
When this workflow is executed, the Iterator step will execute the steps after the Iterator step for each item in the JSON Array. It will replae the data mapped with each item in the array while looping.
You can use the Iterator module with any app integration that gives you data in JSON format.