Using Sub-Flows/Child ProcessesLast Updated: 08/12/2016 Introduced in Verision: 2.0
When using the Flow Designer, it is possible to embed another flow as a step in your parent flow by adding it from the list of available components. This is referred to as adding a “child process” or a “subflow.”
Subflows are added to the Flow Designer by dragging and dropping a step for the flow from the Flows category in the Toolbox. A parent flow will initiate a child flow upon reaching that step in the process and wait for the child flow to complete before moving forward.
To not wait for the child flow to complete before moving forward, use the Start Linked Flow Async (or Fire and Forget Linked Flow) method of calling a subflow; this will invoke the subflow and immediately return control to the parent flow. For more information on this method, see the Invoking Asynchronous Sub-Flows/Child Processes documentation topic.
For many applications, making sub-flows of frequently used steps (such as sending an email, saving an article, creating an alert, or for performing error handling) simplifies your application’s design. It makes your application easier to maintain, since a change in the sub-flow will be reflected in all parent flows. It also helps to unclutter your Flow Designer’s workspace and keep the focus on what key processes are distinct to each flow.
A sub-flow contains all steps, inputs and outputs, to perform a certain function, and can be used as a single step in multiple flows. When an object’s data is contained and hidden in the object, programming languages refer to this as encapsulation.
In the example, we will:
- Edit a Create Insurance Policy flow, which already contains a form and a folder extension data type Create Policy step.
- Introduce an Error Handling subflow, which already exists.
- Introduce a Catch Exception step.
- Map the outputs from the Catch Exception step into the Error Handling subflow.
Begin by navigating to a Designer Folder, and opening our existing Create Insurance Policy flow.
The Flow Designer opens, showing the Insurance Policy Request form and the Create Insurance Request step.
Click OK to save and close the Mapping Editor. Now, if an exception is caught, the sub-flow will execute. This method of invoking a flow will cause the main parent flow to remain in a wait state until the subflow completes, which may not be the desired behavior. To cause control to immediately return to the parent flow upon invoking a subflow, use the “Fire and Forget” method of calling a subflow.
The “Fire and Forget” method of invocation calls a flow in an asynchronous manner. For more information see the Invoking Asynchronous Sub-Flows/Child Processes documentation topic.