Creating and Using Subworkflows
Introduction
The Workflow Framework enables users or systems to create and assign tasks based on user roles and to move those tasks through to completion depending on identified rules. This workflow functionality can be incorporated with other LogicNets frameworks, and it can also be used with subworkflows.
Within a workflow itself you can start up other workflows – subworkflows – using the 'Start Workflow' function. Using the 'Register Subworkflow' and 'Unregister subworkflow' functions you can register/unregister these workflows as subworkflows to your main workflow.
By modeling a 'Wait' task after starting and registering the subworkflows, the 'Wait' task waits until all subworkflows have been finished. The system suspends the main workflow until all subworkflows are finished.
How to Model a Subworkflow
The example project located at the end of this topic demonstrates the steps discussed in this section, and it contains a main workflow and two subworkflows as shown in the picture above. Download the file and import it into your Designer.
In your workflow you assign a post-processing logicnet to your task in the main workflow. In the example project, 'workflow_T' is the main workflow and you assign a postprocess logicnet called 'post_process_T1' to Task T1.
The system then calls 'post_process_T1' each time a user exits task T1. In node 30, the system checks to see if the user exited task T1 by pressing the 'Next' button. If so, the system starts new instances of workflows C and D, which happens in nodes 40 and 60.
The system stores the instance IDs of the started workflows in the data objects 'id_of_sub_workflow_C' and 'id_of_sub_workflow_D'. In node 50 and 70, the system uses these IDs to register the workflows as subworkflows of the main workflow. To register a subworkflow you drag a 'Register Subworkflow' node from the nodes toolbox into your logicnet. In the parameters tab you can then specify the instance ID of the main workflow and the subworkflow that you want to register to the main workflow.
Then add a wait task to the main workflow, right after task T1. To add a wait task, open the nodes toolbox and drag a 'wait task' node to the output of T1.
Connect the output 'Continue' to task T2 and your workflow will wait at this task until the subworkflows are finished. Once the subworkflows are finished, the system continues the main workflow at task T2. Note: You should also remove the 'default' link when this one is connected.
Example Project
Download the Subworkflow Example Project in conjunction with the information above to see how a subworkflow works.