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?
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.
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.
Will a Execution Listener of type ‘start’ work for this?
I created one on the user task and did not work
Error
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
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?
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.
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
task.setAssignee(${var_userId})
Which is not working. I think this is mainly because the Task is already created.
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
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