Any process model you create can also be run as a sub-process of another process model. Appian recommends using sub-processes for any functionality common to your process models.
The Sub-Process Activity is used to launch sub-processes from within your parent process. It links the two published process models and allows you to transfer data between them.
Sub-processes can be run either asynchronously or synchronously.
Asynchronous Sub-Processes - Run independent of the parent process and allow the parent process flow to continue once the sub-process starts.
- They are useful in situations when related activities do not need to communicate back to each other.
- Process variable values can be transferred to the child process, but they cannot be passed back to the parent process.
- They do not allow activity-chaining into a child process from the parent process.
Synchronous Sub-Processes - Places a hold on the parent process flow until the sub-process completes.
- Process variable values can be transferred back and forth between parent and child processes.
- They do allow activity-chaining into a child process from the parent process.
When a process model is started via the Sub-Process Activity, the latest published version of the process model is always used.
- This applies even if the process model was republished after the parent process started (regardless of activity-chaining) or if the Sub-Process Activity is attended and the process model is republished after the user accepted the task but before the user submits it.
- This also applies if the process model is deleted. In that case, the latest published version that existed before the deletion is used. Any data types used by the process model will be frozen to the versions that were current at the time that the process model was deleted. Subsequent data type updates are not reflected in sub-processes that are started after the process model has been deleted.
When a sub-process is edited, an alert is sent to all owners of parent process models that reference the edited sub-process informing them that the sub-process is updated.
When a sub-process completes, delete it (or archive it) to minimize disk-space and memory consumption.
Example Use Case
Ordering business cards is a process associated with a new employee joining the organization. Let's say you configure a Business Card Ordering process as an asynchronous sub-process of a New Employee process. That way when a New Employee process starts, the Order Business Cards process automatically triggers. The parent process (New Employee) continues without needing to wait for the Business Card Ordering process to finish.
See also: Process Model Properties
Linking a Sub-Process to a Parent Process
The steps below describe how to set up a synchronous sub-process. An asynchronous sub-process setup follows the same steps, only you do not configure any output values since no data is returned to the parent process.
- Create and publish the process model you intend to use as a sub-process.
- Open the parent process model for editing, and drag the Sub-Process Activity node onto the canvas.
- Link to it within the process flow at the point you want the sub-process to start.
- Double-click the node to display the Configure Sub-Process dialog box.
- Enter any necessary information on the General tab.
- Click the Setup tab.
- Select whether to run this sub-process synchronously or asynchronously.
- See above for differences between the two.
- (Optional) Select the Enable Activity-Chaining checkbox to create a chain between the parent process and sub-process.
- Click the Directory button next to the Run this Process Model field.
- Locate and select the process model you want to run as a sub-process.
- The Process Variables configured for the sub-process appear on the node variable list. If they do not appear, click Refresh.
- (Optional) Clear the Reporting checkbox to exclude sub-process data from your parent-process reports.
- (Optional) Select the Security checkbox to apply the security settings of the parent process to the sub-process.
- If this process is started using an email, leave this option cleared.
- In the Input Variables box, map a parent process variable to each listed sub-process variable so that when the node is executed, data passes from the parent process to your sub-process.
- If any parameters in the sub-process do not receive values from your parent process, they are assigned null values.
- Parent process variables mapped to sub-process variables that are no longer present in the sub-process are ignored. Process parameters should not be removed from the sub-process model if casting of complex PVs from the parent process to the sub-process is involved; otherwise, the sub-process node pauses by exception.
- To pass a variable directly, select the variable from the drop-down.
- To pass a variable as a reference, select the variable from the drop-down and select Pass as reference. See below: Passing a Process Variable as a Reference
- To specify a value other than the available process variables, enter an expression or create one through the Expression Editor.
- In the Output Variables box, map the sub-process variables to process variables in your parent process.
- Click the Add button. A row is added to the Output Variable list with two drop-downs.
- In the first list, select a process variable to store output data from the sub-process.
- In the Pick a sub process variable... field, select a sub-process variable from the list provided. If your sub-process variable does not appear in the list, check to ensure that the process variable in your parent process has the same Type assigned to it.
- Click the Assignment tab and select Run as whoever designed the process model.
- If you change the security settings in the parent process instance, the security settings in the sub-process instance are automatically updated.
- Modify settings on any additional tabs and click OK to save the settings.
NOTE: If you change the Required value for a process parameter in a linked sub-process after you selected it for a Sub-Process Activity, in order to have those changes take effect when the sub-process is kicked off from the parent process, you need to search for and select the sub-process again in the Sub-Process Activity and re-publish your parent process. If the Sub-Process Activity is attended, make sure you export your form first, so you do not have to re-create it.
Opening the Sub-process from the Parent Process
Appian allows you to easily move back and forth between a parent process model and a sub-process model. Each one can be displayed on a tab within the Process Modeler.
- Click the (+) symbol on the Sub-Process Activity node in the parent process.
- The View Sub-Process Model Window displays with the sub-process model as read-only.
- Click the Open and Edit in New Canvas button to open it in a separate tab of the Process Modeler and edit the sub-process.
Passing a Process Variable as a Reference
When a process contains one or more sub-processes, the parent process variable values are commonly passed to the sub-process using Input Variable mappings. With this configuration, at runtime parent process variables are not immediately affected by changes made to a sub-process. The changes are only updated in the parent process when the two processes are synchronized, which occurs when the End Event of the sub-process activates.
One way to avoid this lag in synchronization is to use a reference. By passing a reference to the actual parent process variable instead of its value, the data remains synchronized at all times. Any changes made to the a process variable in the parent process immediately update all referenced sub-process parameter values. Similarly, changes to the referenced value in the sub-process are concurrently reflected in the parent.
- This synchronization is done by selecting the Pass as reference checkbox when mapping the parent process input variables to the sub-process variables on the Setup tab of the Sub-Process Activity in the parent process model.
Reference relationships also work for processes nested within each other. If there is a sub-process located within a sub-process of another process, a referenced process variable can be passed to each nested sub-process.
- The synchronization of this data occurs in the same amount of time for multiple nested sub-processes as when there are only two processes acting on the same referenced value.
- If a process referencing data in another process is archived, it can be saved with the current value of the data, however, the reference is lost.
- If the process is unarchived, the Pass as Reference configuration is NOT restored.
- If multiple instances of a sub-process exist, mapping data as a reference still works.
- The only exception is when your instances are spawned based on an array Process Variable. (Accessible by selecting the Other tab, then Run one instance for each item in [PV].)
- Spawned instances can take references to specific parent process variables, but they cannot take a reference to the array upon which the spawning is based.
- Due to the way that form default values are stored and evaluated, the Pass as Reference configuration cannot be used to set the default value for a form element.
- If form designers wish to use values by reference, they can remove form fields mapped to sub-process parameters and use input mappings on the Setup tab instead.
- Any custom data types incorporated in a sub-process and mapped as a reference must exactly match the CDTs used in the parent process.
- This is especially pertinent when a CDT is deleted. If only the parent process or only the child process includes a restored or updated version of a deleted CDT, but not both, the Pass as Reference configuration fails.
See Also: Ways to Start a Process From a Process