cancel
Showing results for 
Search instead for 
Did you mean: 

How to reassign a user task

shiva_arunachal
Champ in-the-making
Champ in-the-making
Hi,
I want to reassign a task a different user. Since Explorer has the "reassign" option,  i searched the code for explorer and found the below code which i believe does the reassignment:
<blockcode>
// Update assignee
           String selectedUser = involvePeoplePopupWindow.getSelectedUserId();
           String originAssignee = task.getAssignee();
           task.setAssignee(selectedUser);
           if (selectedUser != null) {
             ProcessEngines.getDefaultProcessEngine().getTaskService().setAssignee(task.getId(), selectedUser);
           } else if (originAssignee != null) {
             ProcessEngines.getDefaultProcessEngine().getTaskService().deleteUserIdentityLink(task.getId(), originAssignee, IdentityLinkType.ASSIGNEE);
           } else {
             return;
           }
</blockcode>

Now i understand 
 task.setAssignee(selectedUser);
.
But why is a call made on taskService also? is the above call not sufficient.
ProcessEngines.getDefaultProcessEngine().getTaskService().setAssignee(task.getId(), selectedUser);


Second question: can the same be effected through the usage of below methods only on taskService?
TaskService.addUserIdentityLink(String, String, String)
TaskService.addGroupIdentityLink(String, String, String)



4 REPLIES 4

shiva_arunachal
Champ in-the-making
Champ in-the-making
Previously i was doing reassigning by looping back on the usertask with a flag with the processvariable value of "assigneeName" changed.

jbarrez
Star Contributor
Star Contributor
> But why is a call made on taskService also?

Actually, the call on the taskservice is the important one, it will update the database. The task.setAssignee won't do that. I'm assuming that happens because of the UI code hooking in into that object to display the assignee.

> Second question: can the same be effected through the usage of below methods only on taskService?

No, assignee is set on the task. Although that information is probably copied into the identitylink. but it definitely needs to be set on the task.

shiva_arunachal
Champ in-the-making
Champ in-the-making
Thanks for the information. What you mentioned is valuable. unfortunately, it is not documented anywhere in user guide, AFAIK.

jbarrez
Star Contributor
Star Contributor
No, that is probably true (haven't checked). That is why open source code is great: you can actually look inside the source and see what happens …