Hi all,
Using Camunda 7.15.
This specific Service Task will be handled entirely by API Rest, so no Java solutions.
What I am trying to achieve: Start a multi-instance activity of type Service Task. The variables (local+global) from each instance have to be both accessible during the Fetch&Lock AND during “any-time” (ie: using /engine-rest/variable-instance/..).
What I achieved so far:
- Process .bpmn has been designed and deployed.
- The process definition can be started.
- I can create processes instances for it.
- The “multi” part of instances is working (ie: I can create N parallel tasks, each with their own
itemfrom theInputCollection). - I can see all (local+global) variables during Fetch&Lock, but I am not able to re-visit the variables using any other API.
Problem: I noticed the LocalVariables (even the “default” ones: loopCounter and the item (from InputCollection)) have a totally different executionId vs the expected (?) executionId which would be from each parallel sub-task instance. With that, I am not able to use the Variable Filter because I can not differentiate which variable belongs to which instance.
In hope of putting it into words in a digestible way.
Imagine a process-instance with 2 parallel instances inside an Multi-Instance activity. The process-instance has a variable on its scope "number": 42. The InputCollection is ["aaa", "bbb"] and there are no localVariables for each parallel subtask.
Doing a GET to engine-rest/process-instance/{id}/activity-instances, I get the following tree:
- 01
executionIdfor the process instance (lets call this PIID) - Inside of it, 03
executionIdsfor themultiInstanceBody(lets call these MIB, T1, T2) - Inside the
multiInstanceBody, the are 02 children (one for each parallel subtask), each with their ownexecutionId(lets call these PST1, PST2*)
– Process Instance –
If I check for variables processId = PIID, I can see number=42; OK so far,
– Multi Instance Body –
I assume MIB is the “legit” executionId for the multiInstanceBody, since it has the 03 “special” variables (nrOfInstances, nrOfCompletedInstances, nrOfActiveInstances)
Here comes the weird part: Both T1 and T2 have the LocalVariables from the “parallelization”
- T1 has
loopCounter=0,item="aaa" - T2 has
loopCounter=1,item="bbb"
– Parallel (sub) Service Task –
Both PST1 and PST2 retrieves no LOCAL variables attached to them (which is expected, since no variables were initialized on their scope).
And, here is the problem: I have no easy way to co-relate 1:1 the executionIds T1, T2 from the multiInstanceBody with the executionIds PST1, PST2 from the children. Filtering for ActivityInstancesIn (and supplying each sub-task’s own activityInstanceId) also returns no variables (local or global).
Worth to say that this DOES NOT happen when dealing with User Tasks — For this very same scenario, the multiInstanceBody would only have 01 executionId and each child parallel subtask would have the LocalVariables (loopCounter, item) within their executionId scope. Filtering variables for EITHER activityInstancesIn=[subtaskN...] or executionIdIn=[subtaskN] would work perfectly.
What gives? Am I misunderstanding the feature or usage of the process-engine, or is this some weird behaviour caused by something silly for this use case?
Thank you very much in advance.

