- Updated on 12 Jun 2013
- 3 minutes to read
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 .
This video shows calling a child process to perform a custom action of "feeding multiple ducks." A process data folder is created for each duck fed to demonstrate how to record process data as child data of a parent process.
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 theInsurance Policy Request form and the Create Insurance Request step.
The output from the form is mapped to the Create Insurance Request step.
In the Components panel, expand the category Flows . Inside is a tree containing flows available to be embedded as sub-flows. Expand the folder in which the Error Handling flow exists. Drag and drop the Error Handling flow into the workspace. In our example, the error handling flow simply contains a form that tasks a Portal Administrator with handling the error. The form uses form labels to show the error information generated from the Catch Exception step, which we will introduce next.
Expand the Flow Management component category in the Toolbox panel. Drag and drop the Catch Exception component into the workspace. Connect the steps as follows:
Only thing left to do is map the data collected from the Catch Exception step into the Error Handling Flow .
Click on the Error Handling flow and from the Actions Toolbar , click Edit Mapping Inputs . Next, drag anchors from the data elements outputted by the Catch Exception step to their respective input nodes on the Error Handling Flow 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.