AnsweredAssumed Answered

Difference between taskService createTaskQuery with includeProcessVariables and includeTaskLocalVariables and taskService.getVariables

Question asked by willems.chris on Nov 6, 2018

Hi, 

 

For getting my tasks with processVariables, I use the following: 

 

result = engine.getTaskService().createTaskQuery().includeProcessVariables().includeTaskLocalVariables().processVariableValueEquals(TENANT_ID, tenantId).list();

Which works fine for most workflows, except for workflows which have sub Processes and where I update task variables locally.  I only get the correct variables back when I use

engine.getTaskService().getVariables(taskId);

Not only do I get more variables back with the second call  ( like nrOfActiveInstances, nrOfCompletedInstances, ...), but I also get the correct values back that I updated locally. 


I mostly update the variables in a class extended from ExecutionListener

 

public void notify(DelegateExecution execution) {
     execution.setVariableLocal(workflowPropertyName, result);
}

So my question is why do the 2 calls return different results ? Is it because I set my variable on execution (runtime) level and not on task level ?  And what can be a solution to do it in one call instead of calling 

getTaskService().getVariables(taskId)

for each task.

Kind regards,

Chris 

Outcomes