Adjusting at runtime what sub flows are run from flow engineLast Updated: 08/08/2016 Introduced in Verision: 2.0
Flows can call sub flows. The choice of which sub flow is called can be made at design time (see: Using Sub-Flows) or at run time. This article shows how to configure your flow to determine which sub flow to call at run time.
You want to build a help desk system that is very modular and allows you to easily create new ways of handling requests based on the type of request.
To begin, Create a Folder Entity called RequestTypeFlowPair with two string properties called RequestType and FlowId.
Create a root folder named Request Type Flow Pairs. After creating this folder, get its id (to be used later) by clicking Actions>Manage>Get Folder URL. The GUID portion of this URL is the folder id.
Create a new Designer Folder named HelpDesk Flows.
Inside this Designer Folder create a form named Enter New Request Type Flow Pair and configure it as shown below.
In this same designer project create a flow named Create New Request Type Flow Pair. First add your Form and then the Create Request TypeFlowPair step. You will find a step for creating a new RequestTypeFlowPair in the toolbox at Integration>Folder Entity Data Structures>RequestTypeFlowPair>Create RequestTypeFlowPair.
Configure the input mapping for the Create New RequestTypePair step as shown below. Note: FolderId value is the folder Id of the root folder you created above.
Create another flow called Request Help. This flow will contain the dynamic sub flow selection.
Place the Get All RequestTypeFlowPair step as the first step in your flow. This step can be found in Integration>Folder Entity Data Structures>RequestTypeFlowPair.
In this flow create a simple form called Request Help Form and configure it with a dropdown and a button as shown below.
Close this form and map in the data from the Get All RequestTypeFlowPair.
After the flow, add a Linked Flow step and select to create a new flow. When the new flow editor opens you can leave the flow empty but make sure to set its input and output data the same as the input/output data of the flows you expect to call (in this example both will be empty). Selecting this flow is only setting the “signature” (combination of input and output data) of the flow this step expects to call dynamically. Once you have created this flow, close and save it which will bring you back to the properties of the Linked Flow step.
Check the Runtime Selection Enabled checkbox and set the value of TargetId to Selected Request Type Flow Pair.FlowId.
For sake of illustration create two simple flows called Software Request and General Request.
Run your Create New Request Type Flow Pair flow twice to create a new request type flow pair for the Software and General request flows you just created.
Now you can run the Request Help flow which will show a list of flows you configured using your Create New Request Type Flow Pair flow. Depending on which request type you select, the corresponding flow will be called.