Are Variables set inside subprocess accessible outside the subprocess?

I was reading this documentation :

http://www.flowable.org/docs/userguide/index.html#bpmnEventSubprocessExample

In this example it is shown that, if event subprocess is defined inside the embedded subprocess then, it has access to the subprocess variables and event is defined at the boundary, it doesn’t have access to the variables. So i created my own test process and behaviour looks different. Can someone explain it to me?

This is my sample process diagram.

p5

When i started the process, the 1st form value was empty as expected.

p1

Then i filled its value and 2nd task came up with empty form as expected.

p2

After filling its value, the subprocess ended with end error event, which triggered the end error event flow. By the documentation, if the variable of sub process should not be accessible outside the subprocess, but when the main process user task comes up, the value of the variables is filled with the value i filled up in subprocess form.

p3

p4

Can someone plz explain me what am i doing wrong.

Also, can someone confirm me that, by creating an embedded subprocess, no new processInstanceId is created as opposed to case in callActivity task. Only new executionId is created. All the variables of subprocess are stored at the processInstance scope i.e. all variables are accessible on the main process instance even after sub process has ended.

Thank You,
Arpit

Hi,

Waiting for a reply!!!

Thanks

Hi,

In the example you provided the form variables will become available as process level variables by default. There’s also a possibility to use local variables through the API, but the Flowable Task application will set the form variables on the process level, and that’s why you see them outside the subprocess as well.
So by just adding an embedded sub process it’s not the default behaviour that variables are set on sub process scope. You could do this via the RuntimeService API or DelegateExecution, by using the setVariableLocal methods.

Best regards,

Tijs

1 Like