After a business process template is defined, you can use BusinessProcessService in the code to create and start a process instance based on the template. It contains two steps:
Step 1: Invoke createProcess method.
To create a new process instance, you need to call the createProcess method on BusinessProcessService.
123
<T extends BusinessProcessModel> createProcess(String processCode, String processDefinitionName)
Note
The first parameter indicates the ID of the process instance. And the second parameter indicates the name of the business process template.
Step2: Invoke startProcess method
To start a process instance, use this code:
1234
void startProcess(BusinessProcessModel process)
The parameter indicates the business process instance to be started.
For instance, the code snippet below establishes a process instance labeled "myProcID", which is derived from the process template "myProcDefinitionTemplateID". After it's created, the process instance, "myProcID" is initiated.
1234
BusinessProcessModel process = businessProcessService.createProcess("myProcID", "myProcDefinitionTemplateID");
businessProcessService.startProcess(process)
For the sake of simplicity, you can also use the startProcess() method to create and start a business process in a single step.
For example:
123
BusinessProcessModel process = businessProcessService.startProcess("myProcID", "myProcDefinitionTemplateID");
Look up Process Instances
BusinessProcessService provides a method to look up business process instances based on a given ID.
123
getProcess (final String processCode)
In the following example, we attempt to retrieve a process instance using the ID "myProcID":
123
BusinessProcessModel process = businessProcessService.getProcess("myProcID");
We've just covered a wealth of theory that you may be eager to see applied in a practical setting. As Process Templates form the foundation of our order management module, we'll delve deeper into the technical aspects in the upcoming Order Management Unit. Additionally, this unit will provide a practical example of how the standard order management business process templates are implemented, customized to meet specific business needs, initiated, and monitored in Backoffice.