How to Complete a Parent Step From a Sub-Process

Sub-processes are a great way to embed reusable processes inside your primary process. The most common design pattern is to use a system step in the parent process as a container for the sub-process. See below for best practices showing how to set up parent container steps and to proceed the parent from the subflow:

1. Set Processing Frequency to Never on parent step. If a step has no other purpose than being a container for a sub-process, it does not need to be evaluated at a regular intervals. We will instead use the sub-process to advance the parent step once it is complete.

2. Add the Start Subflow action to the container step and set up the following parameters:

  • Make sure Lock Parent is set so parent waits for sub-process to complete
  • If you want to use variables from the parent in the sub-process, check Inherit Variables
  • If you want to store the ID of the sub-process instance as a variable, supply a value in Variable Name

3. In the sub-process, add a Call Apex action on the connector(s) going to the End step:

4. Set up the following parameters in the Call Apex action dialog:

  • Keep Work Relay API checkbox field checked
  • Select WorkflowProceedService from API Class Name dropdown
  • Select completeParentStep from API Method Name dropdown
  • Using Advanced mode, select the ID from the $Cursor context object and insert into the cursorId parameter
  • Type "Proceed" under operation (other options include Approve/Reject for decision steps)
  • The only time you need to supply a value (true) on ignoreLockException is if there is more than one subflow on the parent step. In this case, each subflow with a connector to the End step should have the same Call Apex action with a value of "true" for this parameter.