Multi instance task (REST API)

Hi
I’m using a multi instance task, and when I start a process, I post a variable which will be use in the multi
instance “Collection”.
Error: HTTP Status 500 - org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException:
org.camunda.spin.impl.json.jackson.JacksonJsonNode cannot be cast to java.lang.String

Collection variable in Task block:

${S(’{“users”: [“peter”,“john”]}’).prop(“users”).elements()}

XML Task:

<bpmn:userTask id="UserTask_19" name="Task_Assignee" camunda:formKey="embedded:app:forms/1-assignee.html"  camunda:assignee="${assigneeInstance}">
      <bpmn:documentation></bpmn:documentation>
      <bpmn:incoming>SequenceFlow1</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_01p2gmu</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics camunda:collection="${S(&#39;{&#34;users&#34;: 
[&#34;peter&#34;,&#34;john&#34;]}&#39;).prop(&#34;users&#34;).elements()}" 
camunda:elementVariable="assigneeInstance" />
</bpmn:userTask>

How can I set a Collection Variable with the REST API please ?

Thanks a lot for any help
Leo

Hi @ALeo,

your example works so far. There is only a small mistake in the assignee expression which must be ${assigneeInstance.stringValue()} because you iterate over a collection of JSON nodes.

Does this help you?

Best regards,
Philipp

1 Like

@ALeo here is a example where we went through some more advanced usage of JSON arrays and Multi-instance tasks.

Philipp, thanks for your answer.