How can we filter for tasks NOT assigned to a given user?

Hey Camunda users,

I’ve been trying to figure out an easy way to filter for tasks not assigned to a given user. something similar to:

TaskQueryDto queryDto = new TaskQueryDto();
queryDto.setActive(true); // I need active tasks
queryDto.setInvolvedUser(reqUserId); // For a given user
queryDto.setAssigneeExpression("${!’" + reqUserId + “’}”); // But are not assigned to the user

I am hoping there is an easy way to negate the result via the assignee expression but I may be wrong.
Also, the TaskQuery has an or() / endOr() but it doesn’t provide a negation like a not() / endNot().

Is it possible to use such an assignee expression that’s negating the result set?
${! someUserName }?

Hi @paulbors,

you can only negate boolean variables.

The assignee should be a string.

But you could implement any list logic in a bean method that returns a string and filter a list based on any parameter that you pass. You can call your bean with an expression as well.

Hope this helps, Ingo