An example of the XML of a script task is:
<bpmn2:serviceTask id="Task_0gpdh83" name="Order script" implementation="script.EXECUTE"> <bpmn2:documentation>A script to loop and update the list of orders.</bpmn2:documentation> </bpmn2:serviceTask>
An example of the Extensions Editor JSON of a process containing a script task is:
"constants": { "Task_0ykbcv0": { "_activiti_script_": { "value": "order-script" } } }
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>
Note:
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>
Note: The completion condition will be met when 60% of instances have
been completed and the remaining 4 instances will be canceled.
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>
Note: 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"]