To implement a multi-instance process, we have to perform the following steps:
TrainingRequest
process covered in Chapter 6, The Activiti ProcessEngine API. The TrainingRequest
process is shown in the following screenshot:isSequential
parameter of multi-instance. If the value is true
, Activiti will execute in a sequential order; if false
, it will execute in parallel. By default, the value is set to false
.Business Development
task, we can set the Multi Instance property's Loop cardinality value to some positive value, as provided in the following screenshot:loopCardinality
value, the task will execute for that number of times.loopCardinality
, we can set a dynamic value too, as shown in the highlighted code in the following block:<userTask id="usertask1" name="Business Development Executive" activiti:assignee="gonzo"> <extensionElements> <activiti:formProperty id="custName" name="Customer Name" type="string" expression="${customerName}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainTopic" name="Training Topic" type="string" expression="${trainingTopic}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainDate" name="Training Date" type="date" expression="${trainingDate}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainerName" name="Trainer Name" type="string" required="true"></activiti:formProperty> <activiti:formProperty id="trainerMailId" name="Trainer Id" type="string" required="true"></activiti:formProperty> </extensionElements> <multiInstanceLoopCharacteristics isSequential="true"> <loopCardinality>${loopCounter}</loopCardinality> </multiInstanceLoopCharacteristics> </userTask>
<userTask id="usertask1" name="Business Development Executive" activiti:assignee="gonzo"> <extensionElements> <activiti:formProperty id="custName" name="Customer Name" type="string" expression="${customerName}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainTopic" name="Training Topic" type="string" expression="${trainingTopic}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainDate" name="Training Date" type="date" expression="${trainingDate}" writable="false"></activiti:formProperty> <activiti:formProperty id="trainerName" name="Trainer Name" type="string" required="true"></activiti:formProperty> <activiti:formProperty id="trainerMailId" name="Trainer Id" type="string" required="true"></activiti:formProperty> </extensionElements> <multiInstanceLoopCharacteristics isSequential="true" activiti:collection="BDMList" activiti:elementVariable="bdmName"> </multiInstanceLoopCharacteristics> </userTask>