Task loops can made based on conditions, cardinality, and/or a collection.
Multi instance loop.
Sequential loops is the default, or isSequential="true" as the scheme states.
Parallel loops, or isSequential="false" as the scheme states, requires either collection or cardinality.
Behaves as a sequential multi instance loop.
Cardinality is defined as an XML-attribute: loopMaximum="4". An expression can be used as well.
Loop a fixed number of times or until number of iterations match cardinality. The cardinality body an integer or an expression.
<bpmn:loopCardinality xsi:type="bpmn:tFormalExpression">${environment.variables.maxCardinality}</bpmn:loopCardinality>or as activity behaviour
{
"id": "task1",
"type": "bpmn:UserTask",
"behaviour": {
"loopCharacteristics": {
"loopCardinality": "${environment.variables.maxCardinality}"
}
}
}Loop until condition is met. The condition body can be a script or an expression.
<bpmn:completionCondition xsi:type="tFormalExpression">${environment.services.condition(content.index)}</bpmn:completionCondition>or as activity behaviour
{
"id": "task1",
"type": "bpmn:UserTask",
"behaviour": {
"loopCharacteristics": {
"completionCondition": "${environment.services.condition(content.index)}"
}
}
}Loop all items in a list. The collection and elementVariable attributes are schema extensions. They are picked up and resolved when executing the task.
<bpmn:multiInstanceLoopCharacteristics isSequential="true" js:collection="${environment.variables.list}" js:elementVariable="listItem" />or as activity behaviour
{
"id": "task1",
"type": "bpmn:UserTask",
"behaviour": {
"loopCharacteristics": {
"collection": "${environment.variables.list}",
"elementVariable": "listItem"
}
}
}