cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve valid assignees of given task

limcheekin
Champ on-the-rise
Champ on-the-rise
Hi there,

Below are some possible ways to specify valid assignees (potentialOwner) of userTask:

<userTask id="theTask" name="my task" activiti:candidateUsers="kermit, gonzo" />
Valid assignees = kermit and gonzo


<userTask id="theTask" name="my task" activiti:candidateGroups="management, accountancy" />
Valid assignees = All members of management and accountancy group


<userTask id="handleRequest" name="Handle vacation request"
      activiti:form="/vacationRequest/approval" >
……………
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>management</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>        
</userTask>
Valid assignees = All members of management group

I couldn't found any way to retrieve valid assignees in Activiti 5.0.beta1. (Please let's me know if there is a way)

I would like to propose to add method below to Task interface:

        List<User> Task.getAssignees()

What do you think?

Best regards,
Chee Kin
8 REPLIES 8

turgayz
Champ in-the-making
Champ in-the-making
I tried the following but seems like CommandContext.getCurrent() is null when you cast a Task to TaskEntity:

List<Task> tasks = taskService.findUnassignedTasks("fozzie");
Task task = tasks.get(0);
TaskEntity taskEntity = (TaskEntity) task;
Set<TaskInvolvementEntity> candidates = taskEntity.getCandidates();

Getting a NullPointerException at the last line.
There must be a way to get this, but I don't know how!

jbarrez
Star Contributor
Star Contributor
On the identityService:

List<Group> findGroupsByUserId(String userId)
List<User> findUsersByGroupId(String groupId);

limcheekin
Champ on-the-rise
Champ on-the-rise
On the identityService:

List<Group> findGroupsByUserId(String userId)
List<User> findUsersByGroupId(String groupId);

Thanks for response. I awared that these API in identityService, but that doesn't help. Let's say I want to re-assign the task to other user, how do I know it is valid assignee of given task? That's the reason the application need to retrieve the list of valid assignee first prior to re-assignment.

Regards,
Chee Kin

jbarrez
Star Contributor
Star Contributor
Can't you just check then the if the user is inside one of the candidate(-groups) ? That information is not removed when the assignee is assigned.

limcheekin
Champ on-the-rise
Champ on-the-rise
Thanks for response and your patient. Maybe I don't understand your message or perhaps I used the wrong word. Given the image below, If I want to assign the task to an user (Assignee column), the application need to retrieve all valid candidates first, right? How do current Activiti API support this?

Please advice. Thanks.

[attachment=0]AllTasks.jpg[/attachment]

Regards,
Chee Kin

tombaeyens
Champ in-the-making
Champ in-the-making
there is currently no way through our identity service to obtain the users yet.

as part of http://jira.codehaus.org/browse/ACT-104 (Replace findXxx methods returning lists with query API), there will be an api offered that should look like this: identityService.createUserQuery().list();

limcheekin
Champ on-the-rise
Champ on-the-rise
there is currently no way through our identity service to obtain the users yet.

as part of http://jira.codehaus.org/browse/ACT-104 (Replace findXxx methods returning lists with query API), there will be an api offered that should look like this: identityService.createUserQuery().list();

Noted. I will watch this issue closely.

Thank you.

Regards,
Chee Kin

maqjav
Champ in-the-making
Champ in-the-making

I just found this thread from 2010, and now in 2017 I have the same question.

How can I get the list of candidates (groups and users) of an user task?

I found the object "UserTask" that contains two lists (candidateUsers and candidateGroups), but I don't know how to return this object with TaskQuery.

Thanks.