cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying users of an active task

khushboo_gupta1
Champ in-the-making
Champ in-the-making

Hi, I have a requirement where I want to remove/add/update the assignee's of an active task. The assignee which i want to modify could also be in pending state. I am using 5.16.4 version of Activiti.

My question is, it is possible to do in 5.16.4 version of Activiti, if not, is such feature added in latest version?

6 REPLIES 6

bassam_al-saror
Star Collaborator
Star Collaborator

I'm not sure about 5.1.6.4 but in latest version you can modify the assignee of an active task.

So, in the latest version, is it possible to add/remove or replace an assignee from an active task?

If yes, can you please point to some examples on how it can be done.

You can call the TaskService set assignee method.

TaskService (Activiti - Engine 5.22.0 API) 

Or you can get the task and update it's assignee and save the changes

Task task = taskService.createTaskQuery().taskId("123").singleResult();

task.setAssignee("newassignee");

taskService.save(task);

You can set to null if you want to unset the assignee. And in case of claimed tasks you can use TaskService (Activiti - Engine 5.22.0 API) 

Thanks Bassam, 

I have one more question - "How can I achieve this for a multi-user task". Suppose there are three assignees in a currently active sequential task :  "User1", "User2", "User3". Of which, User1 is currently active and I want to remove "User1" and "User2" and add new assignee "User4". 

If the user tasks have already been created then it will be the same approach querying for those tasks and updating their assignees. If you are talking about user tasks that haven't been created yet that's something different.

Hi,

In your example you use the method task.setAssignee("newassignee"); I have the same question, but what I have as input is the "ExternalID" of the user, and am struggling to find a way to get the "userId" to use the setter. Is this possible? I mean, to assign a task to someone with ExternalId="xyz" ? Thank you.