About Branching and Merging FlowsLast 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.
Example
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.
Once we’ve named our new flow, select CREATE. The Flow Designer opens.
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.
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.
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.