- 17 May 2021
- 1 Minute to read
Processing Lists of Items using ForEach Step
- Updated on 17 May 2021
- 1 Minute to read
The For Each Step passes individual items from a Collection of items belonging to a defined Data Type to a Flow loop. The Flow loop will then perform the same actions on each item. When every item has been processed, the loop forwards the finished collection to any subsequent steps outside of the loop.
This example obtains a list of all Accounts; for each Account, the Flow will show a Pop Up displaying the Account EmailAddress and Index order number. Below is a downloadable example to import into Decisions.
- Navigate to a Designer Project and select the CREATE FLOW button from the top Action bar.
- Choose Flow, provide a Name, and select CREATE to open the Flow in the Flow Designer.
- Add a GetAll step from the Toolbox panel under INTEGRATION > INTERNAL SERVICES > ACCOUNTSERVICE.
- Add and attach a ForEach step from the ITERATION category in the Toolbox tab to the Done path of the GetAll step.
- Select the ForEach Step to navigate to its Properties tab.The ForEach step is used to process the list of Accounts for this example. However, ForEach steps can be used to take in any DataType.
- Select From Flow map GetAll1_Output to the Collection Input.The ForEach step will output Item and Item Index. Item is the single element of the array being iterated through. Item Index is the order number of that element starting at 0.
Selecting the ForEach step's Collection will adjust the Type from the dropdown menu under DATA.
Note: the Collection DataType and Type DataType must match to iterate through the Collection successfully.
Connect the Done path of the ForEach step to the End step.
- Select From Flow map GetAll1_Output to the Collection Input.
- On the Next outcome path of the ForEach step add a Show Pop-up step from the FAVORITE STEPS category in the Toolbox panel.
- Select the Show Pop UP step.
- Under INPUTS select Item.EmailAddress for the Subject and for Message, select Item Index.Default.
- Connect the Shop Popup step's Done path back to the ForEach step so that it can continue processing the rest of the Collection.
- Save and close with X, if desired.
Select the Debug link from the top Action bar.
The Flow will run in the Debugger and display a Pop Up for each Account's Email Address and the order number in the Collection's Index.