Find Execution Id from a variable saved in it

Hi All,

I’m trying to find the execution id from a variable stored in a process instance. I have tried so far,

runtimeService.createExecutionQuery().processVariableValueEquals("id","123").singleResult().getId()

But this seems to be giving null result. I have set the variable to the delegateExecution in a previous step
as,
delegateExecution.setVariable("id", "123");

Any reason why this does not work?

Hello.

Could you try it this way?

ProcessInstance procInst = runtimeService.createProcessInstanceQuery().includeProcessVariables().variableValueEquals("id", "123").singleResult();
Execution exec = runtimeService.createExecutionQuery().activityId(procInst.getActivityId()).singleResult();
//do stuff with "exec" object