Multi instance with script task

Hi,
I have process where I choose persons from dropdowns, and then I want to put those persons I’ve chosen to collection and use it in multi instance task. I’m trying with script task, but have error: Variable ‘collection’ is not from type ‘Collection’. How can I resolve this? I’m new in Camunda, so here is my example.
Regards, Sandramt.bpmn (4.7 KB)

Hi @sandra,

the multi instance task expects an object from a Java-Collection type. So instead of just writing

var collection = …

you should explicitly create a Java-Collection object.
You can do it like this:

var collection = new java.util.ArrayList();
// fill the collection here

So simply create the object with the full name (including the packagename) and then you can add your values afterwards. With this object you can also use the normal Java-methods like collection.add(…) or collection.size().

Hope that helps.

Regards
Michael

Thank you for your help! I’ll try the way you told me :slight_smile: