Shared variables accessible to all process instances

Hi folks,

I’m looking for a solution to add some global variables which can be later shared and reused by different process instaces instead of passing variables In and Out Mapping in the BPMN files.

Thanks

1 Like

Hi

Could you explain a little more about your use case - fx what kind of data needs to be available to all process instances?

BR
Michael

I need to define a variable in a root process instance and access to its content in sub process instance without mapping it explicitily in the BMPN files.

In another word, I want to set it globally, I can’t find a solution with Camunda Java API that let me able to do this.

Hi @Amine_Safi,

Variables defined in process instance level are accessible from within all embedded scopes including sub-processes.

Below docs might be of help to you

https://docs.camunda.org/manual/7.16/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility

Hi @Amine_Safi,

It would be great if you can share your model or a simplified version of it.

1 Like

This does not apply to processes started via a “call activity”. In that case, variabled must be passed explicitly.

2 Likes

Hi @fml2,

Exactly, this only applies to expanded sub-processes as call activities create new separate process instances of the called definitions so variables need to be passed explicitly in that case.

1 Like

If I understood correctly, it is not possible to use shared variables between a process and a sub-process and I need to pass them explicitly in the BPMN using In/Out mapping.
Thanks.

Hi @Amine_Safi,

This is true if you are using call activity
image

But if expanded sub-process is used then process instance variables are accessible from within the sub-process
image