Reassign a Task

We are trying to find any way to change the assignment of a Task.
I mean, when a task has an assigned user could it be free (assign to nobody) or directly be assigned to a another user ?

It would be great if it can be done inside Task actions.

Thanks,

Hi Toni,

yes, that’s possible. Have a look on the jUnit tests in org.flowable.engine.test.api.task.TaskServiceTest in Flowable source. (e.g. org.flowable.engine.test.api.task.TaskServiceTest#testUnClaimTask)

public void testUnClaimTask() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    User user = identityService.newUser("user");
    identityService.saveUser(user);

    // Claim task the first time
    taskService.claim(task.getId(), user.getId());
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertEquals(user.getId(), task.getAssignee());

    // Unclaim the task
    taskService.unclaim(task.getId());

    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertNull(task.getAssignee());

    taskService.deleteTask(task.getId(), true);
    identityService.deleteUser(user.getId());
}

Regards
Martin

1 Like

Hi Martin,

Cool !
It is very easy this way, and I also have checked that with the REST API.
My regardings is how to achive that with the Process definition in flowable-modeler.
I’m mean some task/script or whatever that free a task from a assigned user.

One use case is when a user has claim a task and later wants to free it to another candidate.

best,

Toni

Hi Toni,

It is possible to unClaim the task in the process model too, but I do not see any use case for it. Could you describe it little bit more? I would say that the unclaim should be invoked from the UI not from the process definition.

Regards
Martin

Hi,

The use case is the “Web List Revision”'s task, (probably it sounds to you, ;)), it could be the case a user has Claim it but has no time to complete it and has to reassign to another user.

Maybe it has more sense to have a way to finish current task and create another one for another user, instead of trying to assign to another user or free to make it available for Claim for any candidate.

Regarding the unClaim action, you are right, I am thinking in UI App, no in process definition, where I will only declare the action.

Many Thnks ,

Toni