Multiple Instances
Overview
A multi-instance activity is a way to define repetition for a specific step in a business process. In programming terms, a multi-instance is similar to a for-each structure: it can execute a specific step, or even an entire subprocess, sequentially or in parallel for each entry in a given collection.
A multi-instance is a normal activity with additional parameters defined (called "multi-instance characteristics") that cause the activity to be executed multiple times at runtime. The following activities can be multi-instance activities:
- User Task
- Script Task
- Service Task
- Manual Task
- Receive Task
- (Embedded) Subprocess
- Call Activity
Gateways and events cannot be set as multi-instances.
As required by the BPMN 2.0 specification, the parent execution that creates the executions for each instance provides the following variables:
- nrOfInstances: The total number of instances.
- nrOfActiveInstances: The number of currently active (i.e., not completed) instances. For sequential multi-instances, this value is always 1.
- nrOfCompletedInstances: The number of completed instances.
Additionally, each created execution has local variables (invisible to other executions and not stored at the process instance level):
- loopCounter: The index of the given instance in the for-each loop.
Task Multiple Instances
Refer to the "Administrative Assistant Approval" node in the Leave Request Process and the "Department Manager Interview" node in the Onboarding Process
Boundary Events and Multiple Instances
A multi-instance is a normal activity, so boundary events can be defined on its boundary. If it is an interrupting boundary event, when it catches an event, all instances in the activity will be destroyed. Take the following multi-instance subprocess as an example:
When the timer is triggered, all instances of the subprocess will be destroyed, regardless of the number of instances or whether the internal activities of the instances are completed.

