Using Sub-FlowsLast Updated: 05/02/2018 Introduced in Version: 2.0
Subflows are added to the Flow Designer by a step that represents an existing flow from the Flows category in the Toolbox. A parent flow will initiate a child flow when it reaches it in the process, and it will wait for the child flow to complete before moving forward.
When using the Flow Designer, you can 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.
If you do not want to wait for the child flow to complete use the Start Linked Flow Async 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 subflows 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 simplify your Flow Designer’s workspace and keep the focus on the key processes that are distinct to each flow.
A subflow contains all of the steps, along with the inputs and outputs, that were created to perform a certain function. They can also 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 this 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 then the subflow will execute. This method of invoking a flow will cause the main parent flow to remain in a wait state until the subflow completes. Sometimes you may want a different behavior. To cause control to immediately return to the parent flow 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.