How to retrieve updated Process variable object in parallel gateway task

For example lets consider above BPMN Model, Firstly i like to store my domain model as java object in this case say(Customer) as process variable.

Question: Lets say I am storing process variable as ( customerID, Customer object) when the process instance start. In each task i am modifying process variable at task level and setting it back to process instance level.

I like to retrieve updated process variable( customer object) all the time. for instance, In the parallel execution of task customer selection, customer creation, if customer creation completed updated process variable (customer object), will that be automatically updated in parallel execution, at customer selection task. or how do we achieve this any idea?

Hi,

yes it is possible, but there are some things you have to consider.
As first if a local variable has the same name like a variable which is on a higher scope the variable on a higher scope is hidden. So either you use a different variable name to easily access the variable or you use execution.getProcessInstance().getVariable("var1") to get the variable from the process instance.

Also make sure that if you want to update the variable on process instance level set the variable on process instance level and not locally. Using setVariable will set the variable on highest scope.

For more information please read the documentation about Variable Scopes as well

Best regards,
Chris

3 Likes