Process instance variable not set from Execution Listener

I am trying to set a variable on a process instance with the following:

public class FlowExecutionListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution delegateExecution) throws Exception {
        delegateExecution.setVariable("isAwaitingFurtherProcessing", true);
        delegateExecution.getProcessInstance().setVariable("isAwaitingFurtherProcessing", true);

    }
}

I’ve deliberately set it in two places here as I’ve been pulling my hair out at trying to retrieve it again when I query for a process instance:

ProcessInstance processInstances = runtimeService.createProcessInstanceQuery().processInstanceId("process_id").active().singleResult();

After querying for the process instance in question and inspecting it in the debugger, there are no variables set. It is the correct process instance, but I am confused why nothing is being set. Any advice would be welcome.

@stephenm Process instance query returns process instance properties only. In order to query process variables you need to query for variable instance

1 Like