cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching tasks for candidateUser

vvstraet
Champ in-the-making
Champ in-the-making
Hello,

A key feature in a workflow-driven application is the tasklist in which tasks can be queried based on certain filters. I'm struggling however with the TaskQuery API as a very common feature is very difficult to implement: Query for a list that contains all the tasks I may get on my todo-list. This involves both the currently assigned tasks and the tasks that are assigned to someone else but for which I am a candidateUser.

I've looked around and found a solution that may solve my problem (but it complicates the Maven setup as a local repo has to be created with the change):
http://forums.activiti.org/en/viewtopic.php?f=4&t=1730&start=0&hilit=candidateuser

However, I think there's a much simpler solution:
Why does an assignee override the fact that someone is a candidateUser? My guess is that it is much simpler - besides being more correct - to add "TaskQuery.unassigned()" to the cases that rely on the task being unassigned than to make TaskQuery.taskCandidateUser(X) only return unassigned tasks …


As a side-note: I do not understand the TaskQuery.involvedUser(X) semantics, but it also does not seem to solve the above problem …
8 REPLIES 8

vvstraet
Champ in-the-making
Champ in-the-making
Maybe the question in my original post was not entirely clear:
Is there a way to achieve this - with sorting, paging, … - without having to modify the Activiti source code?

jbarrez
Star Contributor
Star Contributor
I quickly checked the code, and it seems that taskInvolved should give you that semantics:


  /** Only select tasks for which there exist an {@link IdentityLink} with the given user */
  TaskQuery taskInvolvedUser(String involvedUser);

Did you try the combination of taskInvolved and assignee?

p4w3l
Champ in-the-making
Champ in-the-making
I don't have an example with candidateUser but I have for candidateGroup. The bad thing is that none of below show potential task for 'user':
- single .taskInvolvedUser( userId )
- mixed .taskInvolvedUser( userId ) with .taskAssignee( userId )

The good thing is that single .taskCandidateUser( userId ) works GREAT even for candidateGroup only ( when assignee and cadidateUsers is empty and only candidateGroups is used with a group value )

Still not solved is to get a list that have all tasks userId assigned AND potential task at the same time.

jbarrez
Star Contributor
Star Contributor
Nope, that won't be possible with the current API, because it uses 'and semantics'.

In 5.11, we've added a way to fire off 'native queries', which is what you'd probably need for your use case.

vvstraet
Champ in-the-making
Champ in-the-making
Thanks for the replies. We've adapted the Task.xml for now, but will probably try the native query in 5.11 (when it's available).

jbarrez
Star Contributor
Star Contributor
Check out https://jira.codehaus.org/browse/ACT-1395, I believe it is the same use case as yours.

heymjo
Champ on-the-rise
Champ on-the-rise
we need this as well, vvstraet care to share your modification to Task.xml for this ?

sunilkumartk
Champ on-the-rise
Champ on-the-rise
in version 5.19
i think this is still an issue.

i tried
taskService.createTaskQuery()
                            .taskCandidateGroup("techassessment")
                            .includeProcessVariables()
                            .list();

as I have NOT used .taskUnassigned(), it should have returned everything. It doesnt!!
I think it should have returned everything as default and only unassigned when taskUnassigned is used.

i tried using the Native Query also but i am unable to add process Variables data with it..