Using setVariable with activityId


Okay then. Thanks for your clear explanation.



Hi, is there any rest api endpoint for setting a variable at activity scope?


hi. Does this still work?

I am updating a variable in my sub process scope like this:

PUT request
with variable:
{“value” : “someValue”, “type”: “String”}

but it gives me 405 (method not allowed )


Hi @Urvashi_Prasad,

Task_09wzlbx:5467d99f-bbca-11e8-a5b2-ace2d3a04152#multiInstanceBody is not an execute id but an activity instance id, so this request will not work anyway. On top of that, I guess the # symbol also messes up the URL unless you encode it properly.



Hi @thorben Can you please tell me a way to add/update a variable on a subprocess scope using REST API?

I have been trying for a while now.
I have posted what all i have tried in this topic.



Can anyone please let me know if this feature
is available through REST API or not.?


Hi Urvashi,

I faced the same scenario where I had to save a variable’s value at a specific scope using REST API,
This is what I found

  1. using (hopefully)
  2. Use a unique key for the variable within a multiInstance Process.
  3. You can do a “jugaad (a flexible approach to solving a problem)” :
    • resolve/complete a task with the variable name eg testVar using rest api.
      Use the code below to save a copy of the variable’s last known value at activity scope


execution.setVariableLocal("testVar", execution.getVariable(“testVar”));


Thanks for your response Udit. I ended up doing a similar thing.
Added a process instance variable through rest api, and then use that to post it to sub-process scope.
works for now.


@thorben, I am not sure how #multiInstanceBody should be used. Let’s use the diagram you posted in this diagram. suppose I am in Task (task id = 100) now, and I want to create a variable which can be accessed in the Subprocess(parallel mulit instance) scope. Is it right that the code be like:

execution.setVariable(‘a’, ‘some value’, ‘100#multiInstanceBody’);

I tried this code, but it’s not correct, complaining scope not found.


Hi @liang,

The third parameter must have the following format: <activity ID in BPMN XML>#multiInstanceBody. So let’s say the ID of the activity named Task is task, then the parameter value should be task#multiInstanceBody.

Does that make sense?



@thorben, thanks for your response. that makes sense, and it’s my understanding too.

In the Task:

var activityId = execution.getCurrentActivityId()+’#multiInstanceBody’;
execution.setVariable(‘insId’, ‘some value’, activityId);

In above code I will get an error complaining scope not found.


Hi @liang,

Please share a unit test on github reproducing this and I can take a look.