About Branching and Merging Flows

Last Updated: 08/16/2018 Introduced in Version: 2.0

Branching and merging allows us to process multiple flow steps in parallel, rather than one after the other. You can create branches and mergers by dragging and dropping the Branch Step and Merge Step components to the Flow Designer work space, and structuring the steps which should be run in parallel between them.



In our example project, we will create a new flow to process four forms in parallel. First, we will navigate to our Designer Folder and click the Create Flow button.

Figure 1: Lower Panel Action Bar


Once we’ve named our new flow, select CREATE. The Flow Designer opens. 

Figure 2: Create Flow dialog


Drag and drop the Branch Step and Merge Step from Steps > Flow Management to the work space. 
Any steps that are anchored between the Branch Step and Merge Step will run in parallel. However, this is not a true parallel. The steps will not run at the same time, but each step will be able to accept the same input and send their output to the steps with in their branch. To take advantage of this new structure, anchor multiple form interactions between the branch and merger.

Figure 3: Branch and Merge Steps


In the Steps panel, navigate to Forms [Interaction] > [Current Folder], and drag the previously created, elements to our Flow Designer work space: Form 1, Form 2, Form 3 and Form 4. Keep in mind that in this use case, each form contains an Action button. The Branch Step offers anchors that can be connected to the inputs of our forms. 

Connect a Branch Step to the input of each form then, connect the output of each form to the Merge Step. This will merge the output of all four forms into one input for the end step. All we have to do now is connect our Start and End steps, and our Flow will be ready to test.

Figure 4: Adding forms to Branch step


Stepping through the debugger, we can see how each form is presented in sequence. The debugger is accessed through the Debug Flow link. Each form’s output is held at the Merge step until the other forms have been processed, after which all form data is combined and sent to the end step. 

Looking at the debugger, the forms receive input from the Branch Step. The Merge Step accepts the outputs of all four forms, merges them, and sends a single output to the end step.

Figure 5: Debugging


Branching and merging can also be used in another scenario.
By selecting AllowCancelMerge, two inputs appear to configure within the Input propertiesCancel Pending Forms and Cancel Reason. Cancel Pending Forms is a boolean option that if set to true will cancel all pending forms that have not been satisfied yet. Cancel Reason is stored as a comment within a process folder if a process folder is being utilized. 

In the Merge Step Property Settings there are two Options for the Merge Type: This Flow Only and Include Sub Flows. This Flow Only merges in the current flow. If sub flows are within the branch then, we may need to use the Include Sub Flows Merge Type. When using Include Sub Flows it is important to understand the Scope. For Example, we have a flow called Flow A. Flow A contains sub flow B, and Flow B contains sub flow C. If we use the Include Sub Flows Merge Type in Flow B then, it will only merge in sub flow C.

Figure 6: Allow Cancel Merge property


Additional Resources