I am using ExecutionListener attached on the start event at the Process level through customized parser - I am adding extra logic to process creation.When I create process through 'Call Activity' I want to get BusinessKey of parent.Simplified code accessing parent might look like that:
public void notify(DelegateExecution process) {
String parentId = process.getParentId();//returuns null
ProcessInstance parent = process.getEngineServices().getRuntimeService().createProcessInstanceQuery()
.processInstanceId(parentId).singleResult();
System.out.println(parent.getBusinessKey());
}
But the "parentId" is not available, moreover having the parentId is still not sufficient to get the parent instance, the parent process is not visible (not saved yet I guess), code like that fails as well:
public void notify(DelegateExecution process) {
String parentId = ((ExecutionEntity)process).getSuperExecution().getProcessInstanceId();
ProcessInstance parent = process.getEngineServices().getRuntimeService().createProcessInstanceQuery()
.processInstanceId(parentId).singleResult();//returns null
System.out.println(parent.getBusinessKey());
}
Code that works looks like that:
public void notify(DelegateExecution process) {
ExecutionEntity parent = ((ExecutionEntity)process).getSuperExecution();
System.out.println(parent.getBusinessKey());//success
}
But according to User Guide classes such as ExecutionEntity shall not be use as they may change in future releases.Is there a way to get the ProcessInstance/BusinessKey of the parent process, from withing start execution listener of subprocess created through call activity?