cancel
Showing results for 
Search instead for 
Did you mean: 

Use TaskQuery with taskCandidateUser OR taskAssignee

edufrazao
Champ on-the-rise
Champ on-the-rise
Hi folks. I'm running Activiti 5.17.0, and I'm running a Query like:


List<Task> tasks = taskService.createTaskQuery()
            .taskCandidateUser("user")
            .or()
            .taskAssignee("user")
            .orderByTaskCreateTime()
            .desc()
            .list();


And… This did'n work. Only the tasks where the user is candidate, (where some user group is candidate) is returned.
If I remove the or() and .taskCandidateUser("user"), off course the tasks directly assigneed to the user is found.

My query is wrong?
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi,

You can use the taskCandidateOrAssigned method instead. That's supposed to do what you are looking for.

Best regards,

Hi trademark!
I think that the problem is related with my Identity setup. I dont store users and groups inside activity tables. I have custom session factorys, collecting this data from webservices.

With this setup, it works:

<code>
List<Task> tasks = taskService.createTaskQuery()
    .taskCandidateOrAssigned(logged.getLogin())
    .taskCandidateGroupIn(getUserRoles())
    .orderByTaskCreateTime()
    .desc()
    .list();
</code>

PS: Using taskCandidateOrAssigned returns only candidates, not assigned.

Thank you for your answer.