cancel
Showing results for 
Search instead for 
Did you mean: 

how to create multi instance user task programmatically

atayee_prg
Champ in-the-making
Champ in-the-making
Hi,
plz help me for create multi instance user task programmatically.
Thanks.
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

You can use the UserTask class and then set a MultiInstanceLoopCharacteristics instance.

Best regards,

atayee_prg
Champ in-the-making
Champ in-the-making
Hi Mr ,
this is true?


    TaskService taskService = execution.getEngineServices().getTaskService();
    UserTask task2 = new UserTask();
    MultiInstanceLoopCharacteristics loop = new MultiInstanceLoopCharacteristics();
    loop.setElementVariable("assignee");
    loop.setInputDataItem("notificationFinalUserList");
    task2.setLoopCharacteristics(loop);
    task2.setAssignee(execution.getVariable("assignee").toString());
    taskService.saveTask((Task) task2);

"notificationFinalUserList" is a global variable(collection)

for this :
<userTask id="multiTask" name="Review task" activiti:assignee="${assignee}">
  <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="notificationFinalUserList" activiti:elementVariable="assignee">      
  </multiInstanceLoopCharacteristics>
</userTask>

jbarrez
Star Contributor
Star Contributor
Yes, looks alright. Is something not working, maybe?