An example of the XML of a call activity is:
<bpmn2:callActivity id="Task_5" name="Start request process" calledElement="process-a6d6ca00-cbb6-45d6-ae24-50ef53d37cc4"> <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> </bpmn2:callActivity>
An example of the XML for an element that contains sequential multi-instance elements is:
<bpmn2:multiInstanceLoopCharacteristics isSequential="true" />
An example of the XML for an element that contains parallel multi-instance elements is:
<bpmn2:multiInstanceLoopCharacteristics isSequential="false" />
or
<bpmn2:multiInstanceLoopCharacteristics />
An example of the XML of multi-instance cardinality is:
<bpmn2:multiInstanceLoopCharacteristics> <bpmn2:loopCardinality>5</bpmn2:loopCardinality> </bpmn2:multiInstanceLoopCharacteristics>
An example of the XML of a multi-instance collection is:
<bpmn2:userTask id="UserTask_1n1uk4a" activiti:assignee="${user}"> <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> <bpmn2:multiInstanceLoopCharacteristics activiti:collection="${userList.users}" activiti:elementVariable="user"> </bpmn2:multiInstanceLoopCharacteristics> </bpmn2:userTask>
The activiti:collection references a process variable called userList that contains the following JSON:
{"users":["user1", "user2", "user3"]}
In the example:
- Three user tasks will be created because there are three items in the process variable that activiti:collection uses.
- A variable will be created for each instance called users with the values user1, user2 and user3 because the activiti:elementVariable is set to "users".
- A user tasks will be assigned to each of the users because the activiti:assignee is set to {users} which is the name of the variable created in each instance by the element variable.
An example of the XML of a multi-instance completion condition is:
<bpmn2:multiInstanceLoopCharacteristics> <bpmn2:loopCardinality>10</bpmn2:loopCardinality> <bpmn2:completionCondition>${nrOfCompletedInstances/nrOfInstances >= 0.6 }</bpmn2:completionCondition> </bpmn2:multiInstanceLoopCharacteristics>
An example of the XML of a multi-instance element is:
<bpmn2:userTask id="UserTask_1n1uk4a" activiti:assignee="${users}"> <bpmn2:multiInstanceLoopCharacteristics isSequential="true"> <bpmn2:loopCardinality>4</bpmn2:loopCardinality> <bpmn2:loopDataOutputRef>choices</bpmn2:loopDataOutputRef> <bpmn2:outputDataItem name="flavor" /> </bpmn2:multiInstanceLoopCharacteristics> </bpmn2:userTask>
The user task will run 4 times sequentially and the values of flavor from the form will be stored as a JSON object in the variable choices. The process variable choices will contain a list of results similar to the following:
["chocolate", "mint", "strawberry"]