Camunda TaskQuery with candidateGroupd doens't work

Hi,

I’m encountered a problem with TaskQuery when taskCandidateGroup query parameter
is set.

In my test, I created two human task where ‘CandidateGroups’ is assigned to a
specified group ‘MASTER_GROUP’.

When I try to execute TaskQuery:

final TaskService taskService = processEngine.getTaskService();
final TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateGroup("MASTER_GROUP");
final List<Task> taskList = taskQuery.orderByTaskCreateTime().asc().listPage(firstResult, maxResults);

This snippet code works fine for unclaimed task; but when I claim one of the two
availble task and, then, I retry to execute the query, it doesn’t work. I obtain
only the unclaimed task. But the claimed task has been claimed with a belonging user to
the MASTER_GROUP.

Therefore I would expect to get both tasks once again where only one of the two (the claimed one) has a valued assignedUser.

Thanks in advance
Giuseppe

Hi @giusebera76,

try to add

taskQuery.includeAssignedTasks()

to sort it out. It is not clear if you expect the claimed tasks in the group task list or if they should be in the personal task list. It’s a common debate as both options are valid.

Hope this helps, Ingo

Hi Ingo,

thanks a lot for your suggestion.

I have just added

taskQuery.includeAssignedTasks()

in my query and now it works fine.

To reply your dubt
It is not clear if you expect the claimed tasks in the group task list or if they should be in the personal task list. I expect to retrieve also the claimed tasks in the group task list: after claimed a task, an user is assigned but the group is the same then I expect to get it by the query.

Thanks in advance
Giuseppe

Hi @giusebera76,

I’ve seen two groups with opposite interests here:

  • the task workers, who are interested in the tasks that are still open to pick work from, excluding assigned tasks
  • the managers who want to see how many tasks have to be completed, including the claimed tasks.

It is important to destinguish both valid views to the same amout of tasks.

Hope this helps, Ingo