cancel
Showing results for 
Search instead for 
Did you mean: 

Some questions in Task query?

bojiang
Champ in-the-making
Champ in-the-making
Hi
    When I want to query tasks ,I use TaskQuery to add some criteria. I want to query all the tasks that a user can do ,including tasks assigned to this user , and tasks can be pulled by this user. I use the below code to do this query.
   
pe.getTaskService().createTaskQuery().taskAssignee("life").taskCandidateUser("life").orderByTaskCreateTime().desc().listPage(0, 1000)
    And I found the generated sql is :
  
select distinct T.* from ACT_RU_TASK T 
            inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = T.ID_
           WHERE T.ASSIGNEE_ = ?
           and T.ASSIGNEE_ is null
           and I.TYPE_ = 'candidate'
           and ( I.USER_ID_ = ? )
           order by T.CREATE_TIME_ desc
  
    First , T.ASSIGNEE_ = ?  and T.ASSIGNEE_ is conflicted.
    Second, if using keyword distinct, the order is sorted, so here i can not get the order order by T.CREATE_TIME_ desc.
 
   Some questions in query .
   1. Is there any existing interface  that can query all the tasks a user can do, or  union  the result in code?
   2. Is there any existing interface that can query tasks by one variable or more variables? If one user want to search a task he can do ,and the tasks have variable a values A and variable b values B, how can I organize the query code with best performance? Query in this table act_ru_variable, more variable criteria,more cycles.
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
Hi,

1) When asking for taskAssignee and candidate in the same query, you get the contradicting T.ASSIGNEE_ clauses. This is because the candidate user/group excludes all tasks that are already assigned.

2) You can use the TaskQuery.taskVariableValueEquals (and in 5.4, also processVariableValueEquals) for this. Per variable you query, a extra join will be made in DB.

bojiang
Champ in-the-making
Champ in-the-making
Hi,

1) When asking for taskAssignee and candidate in the same query, you get the contradicting T.ASSIGNEE_ clauses. This is because the candidate user/group excludes all tasks that are already assigned.

2) You can use the TaskQuery.taskVariableValueEquals (and in 5.4, also processVariableValueEquals) for this. Per variable you query, a extra join will be made in DB.
Thanks for your reply, I'm using version 5.1.
My suggestion is that if there's a heavy query interface that can combine all the runtime tables by different search criterias.
For example , one user log on system, open the work list page, and just one query to list all the tasks that he can do ,including tasks assigned to him,and tasks not assigned but have this user in their coordinate users. Also, this query can combine variable based search.

jbarrez
Star Contributor
Star Contributor
Such a query is not yet possible wioth the public API, but you can of course always write the query yourself if it is really not possible to do it in-mem.