Hey guys,
I am currently facing an issue. Lets say I have a process called X and the other process is Y which is called by Call Activity.
and Y is called as a subprocess by X. But I realised that businesskey of X is cannot be copied for Y. I found a solution that I put a service task just before first task of Y and I called a method in this service task to copy business key of X. But if you take a look below method it seems ok but the problem is process instance alywas null. I couldnt figure why. If you could help me I will be glad. Thanks!
public void updateBusinessKey(DelegateExecution execution) {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables()
.processInstanceId(execution.getId()).singleResult();
String referenceId = (String) processInstance.getProcessVariables().get(PROCESS_REFERENCE_ID);
runtimeService.updateBusinessKey(processInstance.getId(), referenceId);
LOGGER.debug("BusinessKey has been updated succesfully. Process Instance ID : " + processInstance.getId());
}