cancel
Showing results for 
Search instead for 
Did you mean: 

get parent process instance in a child process

hyd198471
Champ in-the-making
Champ in-the-making
Hello everyone,
I have a question regarding to the call activity sub process. In principal, i would like to start a parent process, which has some user tasks and calling activities.
When child process in the calling activity starts, I would like to get the parent process instance. The input param is the task (Task), which is in the case the user task of child process.
<blockcode>
ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();
String parentId =executionEntity.getParentId();
String superExecutionId = executionEntity.getSuperExecutionId();
      
ExecutionEntity rootExecution = (ExecutionEntity)runtimeService.createExecutionQuery().executionId(parentId).singleResult();
ProcessInstance processInstance=runtimeService.createProcessInstanceQuery().processDefinitionId(rootExecution.getProcessDefinitionId()).singleResult();
</blockcode>
Somehow, I dont get the parent process instance. Can someone help to find out how to get the parent process instance?
1 REPLY 1

trademak
Star Contributor
Star Contributor
That's because the transaction wasn't committed to the database yet. You can use the EngineServices instance you can get from a DelegateExecution to use the same transaction context and then you should be able to find it.

Best regards,