I’m trying to use collection from json process variable as Multi Instance Collection property but with no luck
I have JSON variable named “approvers” and “humans” objects collection inside. Tried to use ${approvers.jsonPath(“$.humans”).elements()} as Collection property and got following error:
org.camunda.bpm.engine.ProcessEngineException: Unknown method used in expression: ${approvers.jsonPath("$.humans").elements()}.
Cause: Cannot find method elements with 0 parameters in class org.camunda.spin.impl.json.jackson.query.JacksonJsonPathQuery
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:65)
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:51)
at org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.resolveNrOfInstances(MultiInstanceActivityBehavior.java:107)
Hovewer, looking to this class I see public SpinList<SpinJsonNode> elements() method.
How to get rid of this error? Maybe something is wrong with my expression? Please suggest. I use Camunda via REST API only, no java code from my side involved.
It does not work without the elements because Json can be both an object or a array. The collection of a multi instance needs it to be a Java collection. When you use elements() it types your Json object as a Json list and implements Java collection/list interfaces.