Accessing multi-instance collection data

Hello everyone,

Newbie to Camunda here!

I am trying to use the multi-instance user task but still cannot figure out how to access the specific data of each instance.
So I have a serialized process variable (in Java) set in the previous step and I use this variable in the Collection field (Modeler) of the parallel multi-instance user task.
So I get the correct number of User tasks created. If there are 2 objects in the variable, 2 tasks are created for for the multi-instance task. So far so good!
But how can I access the data of the specific instance of the task.
Either in Java or in user form. For example, each instance created must show the ID of the collection variable. Will this be possible ?

Thank you

Take a look through: Pattern Review: DMN Looping for Array Input

hint: you use the “element variable” to set the name of the variable that will be created in each instance. This is outlined in the Multi-Instance docs, and a thorough example is shown for DMN and bpmn in the link above.

Hi @aruydz7,

All you need is to set the attribute “elementVariable” to a specific name.
Where the process engine will create a new variable with that specific name for each iteration “'task” and assign the iteration’s object of the collection to that variable.

For example: if you have a collection called “employees”, then by setting the “elementVariable” to name “employee”, a new variable named “employee” will be created on each iteration with it’s value set to the iteration’s employee.


Hi @hassang, @StephenOTT
Super quick replies!

@hassang thanks for the clear and simple answer, that’s all I needed! It’s so simple but didn’t see the docs to be this straight forward i guess.