An example of the XML of a user task is:
<bpmn2:userTask id="UserTask_0gpdh83" name="Order" activiti:formKey="form-38098a3e-bff1-46cb-ba0f-0c94fdb287ed" activiti:assignee="${userDetails.username}" activiti:dueDate="2020-01-01T01:00:00" activiti:priority="2"> <bpmn2:documentation>A form to choose the flavor of ice cream.</bpmn2:documentation> <bpmn2:incoming>SequenceFlow_02eaofe</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_14ma5mo</bpmn2:outgoing> </bpmn2:userTask>
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"]