Querying for Tasks without a Candidate Group

I can generate a query that returns me all tasks for a particular set of groups, or are assigned to a specific user, but how do I also specify that I want to include tasks without a candidate group defined in the model?

processEngine.getTaskService().createTaskQuery().active().or().taskCandidateGroupIn(Arrays.asList("admins","managers")).taskAssignee("steve").endOr().list()

If I add “” it doesn’t work, and if I add ‘null’ to the list it throws a NullPointerException.

Thanks Steve

If you don’t want to find tasks based on the candidate group, simply don’t include taskCandidateGroupIn("") as a query parameter.

Hi Niall.

I’m afraid your suggestion doesn’t work. If I leave out the taskCandidateGroupIn("") part of the query it only returns tasks already assigned to “steve”. If I take out that assignee part as well, it returns ALL tasks in an unconstrained way, such as ones for other candidate groups that I don’t want. It really doesn’t look like the API is structured to support the ‘null’, or empty, case in quite a few places.

Kind regards
Steve

Although, saying that it looks like there is actually a

.withoutCandidateGroups()

predicate that can be applied, but that doesn’t work within .or().endOr(), as it throws an exception, so it looks like I’ll have to run two separate queries and combine the results manually. If I include that predicate outside of the ‘or’ group in the query it finds no records even when it should so doesn’t work as one might expect.

For info, the exception is a ProcessEngineException with message “Invalid query usage: cannot set withoutCandidateGroups() within ‘or’ query”