About Branching and Merging FlowsLast Updated: 08/12/2016 Introduced in Verision: 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 workspace, 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 and clicked OK, we’ll be taken to the Flow Designer. After we’ve created some room between our start and end steps, drag and drop Branch Step and Merge Step from the Toolbox panel to our Flow Designer workspace.
In the Components panel, navigate to Forms [Interaction] > [Current Folder], and drag the following elements to our Flow Designer workspace: Form 1, Form 2, Form 3 and Form 4. Our Branch Step offers three anchors to create the flow of input to our forms, but we can create unlimited connections by selecting new anchors that appear within the connections we’ve already made.
After we’ve connected our Branch Step to each form, also connect 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 save and test.
Stepping through the debugger, we can see how each form is presented in sequence. Note that in Decisions version 3.5 and above, the debugger is accessed through the Test 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.
In the Merge Step Settings there are two Options for the Merge Type: ForThisFlow and Global.
ForThisFlow Merge Type is self-explanatory. It Merges only in current Flow. On the other hand, if we have subflows we may need to use Global Merge Type. When using this Merge Type, it is important to understand the Scope. For Example: we have Flow A. Flow A contains sub-Flow B, and Flow B contains sub-Flow C. If we use Global Merge Type in Flow B, it will Merge in its sub-Flow C but will not Merge in the Flow A.