A Sub-process is a separate process that is embedded in another process. Unlike a pool, which generally contains a separate process from another organization, a Sub-process is generally from the same organization as the master process. It can include tasks, sub-processes, events, gateways, etc. The process used by a Sub-process is created just like a normal process in Processmaker, but when the Sub-process is defined in the master process, the process is selected to be used. Cases that include Sub-processes are executed normally, but when the flow arrives at a Sub-process, a new case is created to execute the Sub-process with variables passing between the master process and the Sub-process.
Sub-processes can be used to break up complex processes into smaller units that are more manageable and easier to understand. They can be used to simplify the master process map, so it is easier to understand at a glance, especially when users don't need to see the details of each Sub-process. It is much easier to view a process map with a couple Sub-processes, rather than a couple dozen tasks.
Sub-processes can also be used to control which data is accessible to users. If certain data is sensitive and shouldn't be accessible to all users assigned to a case, that data can be used in a Sub-process, but not passed as variables to the master process.
Another reason to use Sub-processes is because they allow existing processes to be reused in a larger process. If the same sequence of tasks is used in multiple processes, it is recommended to place those tasks in a separate process, which can then be included as a Sub-process in other processes.
In the Shapes toolbox, the Sub-process is represented by a rectangle with a bold border that has a box containing a plus sign inside, like it shows in the image below:
Adding a Sub-process
As shown in the picture below, to add a new Sub-process drag the Sub-process icon from the Shapes toolbox while holding down on the mouse button and drop it into the Process Map.
By default, Sub-processes are named "Sub-process 1", and continuous on depending on the number of Sub-processes needed. To edit the name, double click on it and “Sub-process 1” will be highlighted in blue, then a new name can be given to the Sub-process.
Then press the enter key or click outside the edit box to save changes.
Configuring a Sub-process's Properties
After adding a Sub-process to the Process Map, right click on it and select "Properties" from the context menu.
In the image below, the new opened window has several options, which will be explained in the next four parts.
In this first part, the required information must be filled in for the Sub-process to work correctly. All the fields in this first part have a star next to them, meaning that they have to be added for the Sub-process to work.
In this next image, the Sub-process name is the name added during the creation of the Sub-process and can be changed. In this case the name will be “New Name”.
Then, the second required field is Process, where an existing process is selected to be used as the Sub-process.
Note: Only BPMN Sub-processes can be used in a BPMN master process. Likewise, processes that are created in the classic designer can only use classic Sub-processes.
Another required field is Starting Task. This field selects the task where the case will start in the Sub-process. Only tasks that are connected to a Start Event or Start Message Event in the selected process will be displayed in the list. The Starting Task of the sub-process must have users assigned, otherwise, it won't be available to be selected.
Note: Only tasks, which have assigned users are listed in the Starting Task dropdown.
The next required field is Type, which is very important. The user selects the type of interaction between the master process and the Sub-process. As seen in the image, Type has two options, "Synchronous" and "Asynchronous". Where “Synchronous” means that the master process case will pause and wait for the Sub-processes's case to complete before continuing its execution. When a synchronous Sub-process finishes, variables can be passed from the Sub-process's case back to the master processes case. In an asynchronous process, means the master process does NOT pause and wait for the Sub-process case. Instead, the master process immediately continues with its subsequent tasks. Both the master processes case and the Sub-process's case continue executing in their own separate time, because the master process does not wait for the sub-process.
In this second part, how to use the Variables Out options will be explained. Take into consideration that whenever the type “Asynchronous” is selected, the user will have only the Variables Out option.
Note: The Variables In options will be explained further later this document.
A field with the name “Origin” appears first. It introduces the names of the variables from the master process, which will be passed to the Sub-process.
Click on the @@ symbol to open a new window.
Use the [@@] button to select variables from the master process. Make sure to select the correct variable type so it will be parsed correctly.
After selecting a variable click on “Insert Variable” to close this window and add the chosen variables.
Variables should be referenced as follows so their data type won't be changed:
|Strings (a series of characters)||@@variable|
|Floating-point numbers (Real numbers with a decimal point)||@#variable|
|Other data types (Boolean, array and object)||@=variable|
Next, the Target field lists the target variables, which will receive the values of the variables passed from the master process.
Click on the @@ symbol to open a new window and add a new target variable.
Use the [@@] button to select variables from the master process.
After selecting a variable click on “Insert Variable” to close this window.
Click on the Add button to place the variables in the list of variables to be passed between the master process and the Sub-process.
Then, click on the Save button to maintain all changes. Or, click on the Close button to discard all changes and close the modal window.
Note: The variables added are just for example.
In this part, the use of Variables In options will be explained. If the process is synchronous, a new section called “Variables In” will appear (see image below). This will help select variables from the Sub-process that are passed back to the master process when the Sub-process finishes.
Like with Variables Out, two options are offered: “Origin” and “Target”. Choose variables for both of these options and add them to the Sub-process (as shown with Variables Out).
Then, click on the Save button to maintain all the changes. Or click on the Close button to discard all changes and close the modal window.
Note: The variables added are just for example.
Modifying a Sub-process
Right-click on the sub-process to view the options in the context menu.
Every option will be explained next few sections, expect for Properties, which has already been explained.
Right click on the sub-process shape and select the option Edit Label to edit the label of the sub-process shown in the Process Map. This option allows the name of the Sub-process to be changed.
Delete Routing Rules
To delete all outgoing routing rules from the Sub-process, select the option Delete Routing Rule. In the message window that opens, the user has two options: click Yes to delete all outgoing routing rules from the Sub-process, or click No to close the message without making any modification.
If the routing rules were deleted, a flash message will appear at the top of the Process Map indicating that the routing rules were deleted successfully.
Deleting a Sub-process
To delete a Sub-process element and all configuration and routing rules from the Process Map, select the option Delete to erase the Sub-process completely.
Allowing Processes to be Used Only as Sub-processes
If a process will only be used as a Sub-process and will never be used as a stand-alone process, then it is recommended to mark it as a sub-process, so that it will not appear in the list of available processes when a user creates a new case. To do this, open the process for editing. Right click on a blank area in the Process Map and select Edit Process from the context menu. In the Edit Process window that appears, mark the option “This is a Sub-process” and then click on Save.
Note: After clicking on Save, the process will no longer appear in the list of available processes when the user goes to HOME > New case. The process can only be used as a sub-process that is embedded in a master process.
The following example will explain how to use Sub-processes. A company has safety training that all employees in the company must attend every year, but new employees also need to pass through safety training when they begin employment at the company. Therefore, the "Safety Training Course" process can be run as a separate process for all employees every year or it can be run as a subprocess as part of the "New Employee Onboarding" process. In order to avoid having to implement the safety training twice in ProcessMaker, it is easier to implement it once as a separate process, and then use that process as a subprocess in another process.
First, create the "Safety Training Course" process:
In the safety training course, the employee first reads the safety training manual, then concurrently practices safety with a trainer and takes a written safety test. Both of these tasks have to be completed before the process checks whether the employee passed the test. If the test was passed, then the process ends, but if the test was failed, then the entire process needs to be repeated again.
Then, create the "New Employee Onboarding" process, which will execute the Safety Training Course as a subprocess:
The "New Employee Onboarding" process will be synchronous, meaning that it will need to wait until the "Safety Training Course" subprocess has finished executing before it continues on to the "Company protocol training" task. To define the subprocess when creating the master process, right click on the "Safety training" subprocess and select Properties from the context menu.
Select "Safety Training Course" for the Sub-process and "Read Safety Manual" for the starting task. Then, select "Synchronous" as the Type of subprocess.
Then, specify which variables will be passed from the master process to the subprocess under the Variables Out section. In this example, the @@TrainingType and the @@Trainer variables in the master process will be passed to the @@TrainingCourse and @@TrainerName variables in the subprocess when a case is executed.
When the subprocess is done executing, the variables listed in the Variables In section will be passed back to the master process. In this example, the @@TrainingCourse, @@TrainerName, @=TrainingSchedule and @#TotalHours variables will be passed back to the "New Employee Onboarding" process. Notice that the @=TrainingSchedule is an array that holds the values entered into a grid, so it needs to be specified with @= so its variable type isn't changed. If specified as @@, then it will be converted to a string, which will cause problems if the master process needs to access its values. Likewise, @#TotalHours is a floating point number (i.e., a real number with a decimal point), so it needs to be specified as @#, so it won't be converted.
Note: In the Sub-process properties, the Starting Task field won't appear unless the Process has users assigned. In other words, the master process must be assigned to someone so the Sub-process can work accordingly. Remember that a Sub-process depends on the master Process.
Setting the Assigned User in a Subprocess Case
The assigned user in a subprocess case can be set in the master case by placing the unique ID of the user in a variable and passing that variable to the subprocess.
For example, the following master process contains the "Background Check" subprocess:
Which links to the following subprocess:
The user assigned to the "Investigate Client" task in the master process needs to be the same user who is assigned to the "Check Credit History" task in the subprocess.
First, create a string variable in both the master process and the subprocess named
Then, create a trigger in the master process that stores the unique ID of the user currently logged in to the
Set this trigger to execute before assignment in the "Investigate Client" task in the master process. Then, right click on the subprocess in the master process and select Properties from the context menu. In the Subprocess Properties dialog box, add
@@nextUser to the list of variables that will be passed from the master process to the subprocess.
Then, go to the subprocess and in the Assignment Rules of the "Check Credit History" task, select Value Based Assignment and set its variable to be
@@nextUser. Make sure that the same users who are assigned to the "Investigate Client" task in the master process are also assigned to the "Check Credit History" task. Value based assignment only works if the user ID in the variable is also in the list of users assigned to the task.
When a case is in the master process, the user assigned to the "Investigate Client" task should also be assigned to the "Check Credit History" task in the subprocess.