Update a "counter" process variable (increase/decrease by 1) with REST API


#1

I have a “global” process variable which is a “counter”, defined in a main process.
The main process calls different call activities which may need to update this variable (I use input/output mappings = all).
If I update it in one call activity, then the parent main process (and also the other child call activities) doesn’t see the update until the corresponding call activity finishes.

So, I’m thinking of trying to update the “global” variable with the REST API.
I can use the Modify/Update methods of https://docs.camunda.org/manual/7.8/reference/rest/process-instance/variables/
but how can I increase/decrease the current value by 1 (something like “global_counter +=1”)?
Do I have to make two REST calls, one to retrieve the current value (with the get-variable method) and one with the Modify/Update method?

Then, how will this update be visible in all child call activities? Because due to the mapping, the child process variables will be “local”. Do I have to call again the REST API somehow?