Access called activity's variables before it is completed (out propagation)

Hello all!

I have created a process which has a call activity that calls a “sub process” with three user tasks.
Is there a way that the main process can see the variables created inside the sub process before it (the sub process) is completed?

I have configured in and out propagation. But the variables I am creating by completing the user tasks inside the sub process are available to the main process only when the instance “exits” the called activity.

Can somehow the root process access them before?

Thank you!

Hi @konkouts,

a call activity starts a new process instance and all variables are saved there.

You have to use a separate service task to identify the super process instance and set the variables explicitly.

Hope this helps, Ingo

1 Like

So if I understand correctly, a service task inside the called process that creates the variables also in the super process instance?

Is there an example I can use?

Thank you!

Hi @konkouts,

Keep in mind that setting variables exciplicitly doesn’t mean keeping sync between the two collections of variables (main process and called process).

May we know the purpose of such a requirement?

1 Like

Hi @hassang , of course.

Basically, I wanted to use one request to get all the process instance variables.
So I am using /history/variable-instance?processInstanceIdIn={processInstanceIdIn}

In some cases (after the completion of the sub process) I must use the super process instance id, but when the sub process is not yet completed, I must use the sub process instance id as parameter in the request.

So I was wandering if there was a way to avoid this.

Hi @konkouts

I believe using business key can serve your needs so you can always query using a single business key value and results from both instances (calling and called) should be returned.

1 Like

Here is how you can pass the business key to the called process

@hassang I have thought this option since I am using business key, but the problem is that in the request I am using: Get Variable Instances (history/variable-instance)

https://docs.camunda.org/rest/camunda-bpm-platform/7.19/#tag/Historic-Variable-Instance/operation/getHistoricVariableInstances

does not have an option for business key as a parameter. It only offers processInstanceId

Hi @konkouts

:sweat_smile: just now I realized that. Query by business key is not available.

1 Like

@hassang Yes, at the bottom line this is my issue

If you are using spring boot and it is okay for you to do some extra work then you can extend the endpoint to include querying by business key.

In my project,
I am running Camunda with the Docker installation.
And I am using .NET as a backend service that makes calls to the Camunda API requests.
I am not using spring boot, so I don’t know if this is possible in my implementation.

In that case you need to use spring boot distribution, extend the end point then dockerize the sprint boot application.

1 Like

Thanks @hassang for all the information!

1 Like