Processing Lists of Items using ForEach Step
  • 11 Oct 2022
  • 1 Minute to read
  • Dark
    Light

Processing Lists of Items using ForEach Step

  • Dark
    Light

Article Summary

Overview

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.


Example

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.


This is just one example of how the ForEach step can be used. The ForEach step can iterate through default system data types and user-defined data types to perform any action in a ForEach loop.
  1. Navigate to a Designer Project and select the CREATE FLOW button from the top Action bar.
    1. Choose Flow, provide a Name, and select CREATE to open the Flow in the Flow Designer.
  2. Add a GetAll step from the Toolbox panel under INTEGRATION > INTERNAL SERVICES > ACCOUNTSERVICE.
  3. Add and attach a ForEach step from the ITERATION category in the Toolbox tab to the Done path of the GetAll step.
  4. 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. 
    1. 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.

    2. Connect the Done path of the ForEach step to the End step. 

  5. On the Next outcome path of the ForEach step add a Show Pop-up step from the FAVORITE STEPS category in the Toolbox panel.
  6. Select the Show Pop UP step.
    1. Under INPUTS select Item.EmailAddress for the Subject and for Message, select Item Index.Default
  7. Connect the Shop Popup step's Done path back to the ForEach step so that it can continue processing the rest of the Collection.
  8. Save and close with X, if desired.


Debug

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. 



Was this article helpful?