cancel
Showing results for 
Search instead for 
Did you mean: 

Queries in execution listener

thomasl
Champ in-the-making
Champ in-the-making
Hi,

I have a process which starts subprocesses and I would like to modify variables from the parent process at the end of a subprocess. I have added a ExecutionListener to my processes. This works fine however within the notify(DelagateExecution) method, I do not manage to get the processInstanceId of the parent process since all queries returns null (execution.getVariable(parentId, "myVar") works if I hardcode the parentId).

Is there another way to get the super processInstanceId ?

Thanks,

Tom
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
You can use the activiti:in and activitSmiley Surprisedut to populate parent-process variables using values from the sub-process, when it completes (see userguide). If you really want to do it manually, try casting (instanceof check first) the DelegateExecution to an ExecutionEntity and use the getSuperExecutionId() to retrieve the parent process…

thomasl
Champ in-the-making
Champ in-the-making
Thanks Frederik !

I'll try that. Could it be more straightforward the other way around, i.e. is it possible to easily get subprocess variables from for instance an end event listener of the callActivity ?

(The idea is that I need to merge variables from  the parent and child process, I could use activitiSmiley Surprisedut and a scriptTask afterwards but since this are tedious operations to perform, I would like to make it as transparent as possible to the BPMN script developer).

Thanks,

Tom

frederikherema1
Star Contributor
Star Contributor
I quite sure the an end-execution-listener is called in the execution-context of the parent process, so the DelegateExecution you get there, is not aware of the child-scope, as it will have been destroyed as part of the end-event of the sub-process.

thomasl
Champ in-the-making
Champ in-the-making
Hi Frederik,

Yes you're right. I tried and the sub-process is not available neither at the callActivity start event nor at the end. However, I used a cast in the sub-process end event to retrieve the parent execution as you proposed and it works fine.

Thanks again, it was very helpful.

Tom