Re-assign user task


I have a user task X which I assign to a user using “Assignee” Property using ${var_userId}. I have added a boundary timer that runs every 2 minutes on this user task. After ‘n’ number of tries I want the user task X to be assigned to a new user. I changed the value of var_userId to the new user Id, I see this is reflected when I check the variables, however I still see that the user task X is still assigned to the previous user.

How can I change the assignee using the variable value?

Thanks in advance!

after retry, you can set a flag like reassign=true. Following the timer you can configure service task or listener in user task and check for reassign flag and if condition evaluates to true you can set execution.setAssignee"(otherUser") in listener or delegateTask.setAssignee("otherUser") in delegation code. Or you can use directly claim() api to reassign the task to otherUser.

Hi @aravindhrs

I’m a little confused. Where exactly does execution.setAssignee"(otherUser") need to be added?

Clarifying the flow:
‘Access Approval Form’ user task Assignee is set using ${var_userId}. Every 2 days, the boundary timer is triggered and if the retry counter is more than n days, the ‘Assign Next Escalation’ task is triggered, which modifies the var_userId value to the new user.


Add a listener to the user task and in the listener you can able to write the logic

Will a Execution Listener of type ‘start’ work for this?

I created one on the user task and did not work



org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script while executing activity ‘task_accessApprovalForm’ in the process definition with id … TypeError: execution.setAssignee is not a function in <eval> at line number 2

Hi @etp,

you can use a task listener for this:

The task object has a method to set the assignee.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

Which task event is suited for this scenario? Is ‘Create’ the right Event Type for this scenario? Technically it wouldn’t be right, since the task is already created/started and in-life we are trying to set the Assignee?

Hi @etp,

a quote from the docs:

  • create : occurs when the task has been created and all task properties are set.
  • assignment : occurs when the task is assigned to somebody. Note: when process execution arrives in a userTask, an assignment event will be fired first, before the create event is fired. This might seem like an unnatural order but the reason is pragmatic: when receiving the create event, we usually want to inspect all properties of the task, including the assignee.

I would use create.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier ,

I tried the Create task event and wrote an expression as


It however does not work. Is this correct? Or this needs to be something like


If an example can be provided, it would be of much help

Hi @etp,

all variables are directly accessible in expressions:

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

This is pretty much the same thing I have done. In the user task that needs to be reassigned, I have a Task Listener with Event Type ‘Create’ and Listener Type ‘Expression’ with


Which is not working. I think this is mainly because the Task is already created.

Any pointers is much appreciated.

I tried changing the flow as


and used the same Task listener as described previously. But I now see that a new task of sorts is getting created and i can see that the activity field is empty

Is there anyway the user task can be reassigned inlife?

Below is how I handled this scenario:

  1. In the user task ‘Access Approval Form’, I created a Task Listener

taskId = task.getId();

  1. In the ‘Assign Next Escalation’ task, where I wanted the User task ‘Access Approval Form’ to get assigned to another user, I used an Execution Listener


And the User Task gets assigned to the new user

Hi @etp,

glad you found something that works for you!

To give you a heads-up: Camunda BPM 7.12 (due November 30, 2019) plans to include time-triggered task listeners as described here:

They can be particularly useful in reassignment scenarios like yours. Feel free to check it out as soon as it’s out there. :slight_smile:


1 Like