How to configure the collection of a multi instance task?

Hello,

I want to model a process with a multi instance task. The task has to be assigned to multiple users. The users are already defined before modelling the process.

Is there a way to define the collection hard coded in the process definition xml without using scripts or Java delegates?
I am looking for something like camunda:collection="['user1', 'user2'].

Thanks.

Hi,

in the documentation you can find an example for this.

You need the list of user names as variable. Call it for example assigneeList. This variable must be used as collection for the Multiinstance. Then define the elementVariable for each Usertask and reference this variable as assignee.
See the complete example below.

<userTask id="miTasks" name="My Task" camunda:assignee="${assignee}">
  <multiInstanceLoopCharacteristics isSequential="false"
     camunda:collection="assigneeList" camunda:elementVariable="assignee" >
  </multiInstanceLoopCharacteristics>
</userTask>

Greets,
Chris

1 Like

Thanks for this quick response.

What you described, is exactly what I am doing now. I set the variable assigneeList in an ExecutionListener script on the sequence flow before the multi instance user task.

Is there any reason for why it is not possible to set static process variables without scripts?

If you have a fixed number of assignees, you can model them explictily, with a parallel gateway or sequence flows.

It’s easier to understand for less experienced readers.

Hope this helps, Ingo

1 Like

I was thinking in the direction of using an input mapping. They allow you to define static lists in the XML. However, an input mapping on a multi-instance activity applies to each inner instance, not to the containing multi-instance body. So to make this work, the input mapping would have to be defined on a containing sub process or similar.

Cheers,
Thorben

1 Like

Hi @mrol,

Could you please share your process definition?

Need a working example that I can refer to.

In my test project the “multi instance” task is initialized twice for each element in the collection list. I cant seem to figure out why. This is my process definition.

test1-multiuserapproval - Copy - Copy.bpmn (5.2 KB)

1 Like

Hi,
you have two outgoing sequence flows from your none start event to script task “Generate Assignees1”. According to BPMN standard, none start event will create token for each outgoing Sequence Flow.
This should answer your question.
Cheers,
Lukas