cancel
Showing results for 
Search instead for 
Did you mean: 

Call Activity and BusinessKey Update

doganmesut
Champ in-the-making
Champ in-the-making
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());
    }
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi doganmesut,

The problem is that data were not flushed to the DB yet, that's why query

ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables()
.processInstanceId(execution.getId()).singleResult();

returns null. Get all neccessary data from execution.

Regards
Martin

doganmesut
Champ in-the-making
Champ in-the-making
Thanks Martin, I got the data via execution.
Here'sa solution for who is having same problem :

@ProcessMethod
    public void updateBusinessKey(DelegateExecution execution) {
        ExecutionEntity executionEntity = (ExecutionEntity) execution;
        ProcessInstance processInstance = executionEntity.getProcessInstance();
        String referenceId = (String) execution.getEngineServices().getRuntimeService().getVariables(execution.getId())
                .get(PROCESS_REFERENCE_ID);
            runtimeService.updateBusinessKey(processInstance.getProcessInstanceId(), referenceId);
    }