CMMN/BPMN: Find all User tasks by Variable (strange behavior)

Is it possible to send one API request to get all UserTasks by specific variable, independently if they are in CMMN or BPMN?

taskService.createTaskInstanceQuery().caseInstanceVariableValueEquals(…).list()
taskService.createTaskInstanceQuery().processInstanceVariableValueEquals(…).list()

Actually, I would like to search for UserTasks which are active and have a specific variable value, independently of the scope of the variable.

Currently, it seems only this is the way to do this:

taskResult.addAll(taskService.createTaskInstanceQuery().caseInstanceVariableValueEquals(…).list())
taskResult.addAll(taskService.createTaskInstanceQuery().processInstanceVariableValueEquals(…).list())
and maybe:
taskResult.addAll(taskService.createTaskInstanceQuery().taskVariableValueEquals(…).list())

But that are two (three) requests instead of one.

EDIT:
I have now a process invoked from a case. The case propagates all variables to the process.

If I search now with caseInstanceVariableValueEquals(…), I find also the UserTask of the BPMN process. Vice versa, I am not able to find UserTasks of CMMN cases via processInstanceVariableValueEquals(…).
That’s a really strange behavior of the engine.

BR,
Michael

Hi Michael,

in Camunda 7.8, you can create a task query with OR criteria. Please have a look at the blog post.

Does it work for you?

Best regards,
Philipp

2 Likes