Multi-instance allows for the element to be repeated within a process. There are two options for how to execute multi-instance elements: sequentially or in parallel.
- Sequential executions only ever have a single instance running at any one time. The next instance will only start after the previous one has been completed.
- Parallel executions start all instances at once, meaning they are all active and can all be worked on at the same time.
Multi-instance elements are displayed as three parallel lines at the bottom of the original element. Sequential lines are horizontal and parallel lines are vertical.
Variables
Each multi-instance execution has three variables:
Variable | Description |
---|---|
nrOfInstances | The total number of instances |
nrOfActiveInstances | The number of currently active instances. For sequential multi-instances, the value will always be 1. |
nrOfCompletedInstances | The number of instances that have already been completed |
These variables can be used in multi-instance expressions without having to be declared as process variables.
Each instance in the multi-instance execution also has an instance-local variable that is not visible to other instances, nor to the process instance:
Variable | Description |
---|---|
loopCounter | The index in the for-each loop of that particular instance |
Cardinality
Cardinality sets the number of instances to be executed by the multi-instance element. This can be set as a static value, a process variable, or calculated as an expression.
Collection
A collection can be used to set the number of instances to be executed by referencing a list of items.
An element variable can optionally be used with a collection. An element variable is used to create a variable for each instance of the multi-instance element and each variable created by the element variable is assigned one value from the collection.
Completion condition
A completion condition can optionally be included for multi-instances. When the completion condition evaluates to true, all remaining instances are canceled and the multi-instance activity ends.
Results
A result collection can be set to aggregate the results from each instance into a variable. The result collection is created as a process variable after instance execution has finished.
The result element variable is used to select the field or variable from the BPMN element to aggregate into the result collection.