Processing Lists of Items with the Branching ForEach Step

Last Updated: 03/15/2016 Introduced in Verision: 2.0

The Branching ForEach Step component iterates through every item in a collection, passing them to one or more next steps. It is similar to a non-branching ForEach Step component, with two major differences. It branches the flow into multiple paths, and the flows following a Branching ForEach Step do not need to complete the loop by forming a return path to the Branching ForEach Step component. The control of the flow will return to the Branching ForEach Step at the flow’s end automatically.

The Branching ForEach Step can be found in the Flow Management category of the Toolbox panel in the Flow Designer.


This example flow will retrieve all of our user accounts and display them individually within a form, [Form] Display Names, which was created for this example.



To begin, navigate to a Designer Projects folder and click the Create Flow button. Name the new flow and click OK to open it in the Flow Designer.



Begin building our flow by placing a Get All component to the workspace from the Integrations > All Integrations > Internal Services > Accounts Service category of the Flow Designer’s startup window.


Also place a Branching ForEach Step component from the Flow Management category. From the category Forms [Interaction] > [Current Folder], drag a [Form] Display Accounts component to the workspace.



Our Branching ForEach step doesn’t know which input is to be iterated over until it is specified at that step. Click on the Branching ForEach step. To set the account object as the input type, from the Properties panel, Collection section, click the Type selector.



Use the search field to locate “account,” select the Account data type, and click OK.


Connect the Get All 1 step to the Branching ForEach step.
Next, map the output of Get All 1, data for all of the system’s accounts, to the Branching ForEach step. Open the Mapping Editor by selecting the Branching ForEach Step and clicking the Show Mapping Editor link.

Conveniently, Get All 1 has only one output, which we map to Collection as GetAll1_Output.

Connect the For Each path out of the Branching ForEach Step to the appropriate [Form] Display Accounts form.

Next, map the output from Branching ForEach Step to the appropriate [Form] Display Accounts input, so we select the form and click the Show Mapping Editor link.



In the Mapping Editor, we can see that there are three distinct inputs available to Display names: a FlowConstantData object (Flow Data), an individual Account item (Item), and the entire collection of Account items (GetAll1_Output, or in this case Output since it was renamed). Since we want to iterate over each Account item individually, map Item to our input Data.



Now that our flow is complete, save and run it in our debugger.

Note that in Decisions version 3.5 and above, you’ll need to click on Test Flow to access the Debugger.

3.5 Test Flow Shot

For each account pulled from our system, a form containing the Account’s details appears. Clicking Done directs control back to Branching ForEach Step 1, which then outputs the next Account item, unless the collection is empty.


We can see the flow’s execution by clicking the Diagram tab.



Additional Resources