cancel
Showing results for 
Search instead for 
Did you mean: 

Unclaim task

marcgr
Champ in-the-making
Champ in-the-making
Hi guys!!
That's my first post Smiley Very Happy. I'm noob on Activiti but I really like it.

So, I'm developing my own explorer and I have a little trouble unclaiming tasks.

That is the way how I claim:
myTask.setAssignee(idUser);
ProcessEngines.getDefaultProcessEngine().getTaskService().claim(myTask.getId(), idUser);

And trying to unclaim I've found in few posts that says "you just need to do: myTask.setAssignee(null)"…
but is not enough. That don't change anything on my database… I tryed doing:
myTask.setAssignee(null);
ProcessEngines.getDefaultProcessEngine().getTaskService().addCandidateGroup(myTask.getId(), null);

but it throws an Exception:
org.activiti.engine.ActivitiException: userId and groupId cannot both be null

It seems like doesn't know where to pool it, isn't it?
What I'm doing wrong??
8 REPLIES 8

gant
Champ in-the-making
Champ in-the-making
Hi,

taskService.setAssignee(task.getId(), null)
works for me.

Regards

marcgr
Champ in-the-making
Champ in-the-making
Hi Gant,

thanks but it doesn't work… It throws the exception too.
But maybe is a version problem (I use 5.1)… Anyway next week I'm going to update to 5.6.
I'll try with next version and if it doesn't work I'll post again Smiley Wink

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
in 5.1 this indeed would not work. Unclaiming was implemented in 5.3 iirc. As is posted in this forum and the wiki. Please use some search functionality first next time…

frankee787
Champ on-the-rise
Champ on-the-rise
I know its a bit outdated post, but is there any difference between

taskService.setAssignee(taskId, null);
and

taskService.claim(taskId, null)
Regards,
Franklin

frederikherema1
Star Contributor
Star Contributor
Yes, an already claimed task will throw an exception when claimed by another user, the setAsisgnee always works…`(see javadoc)

/**
   * Claim responsibility for a task: the given user is made assignee for the task.
   * The difference with {@link #setAssignee(String, String)} is that here
   * a check is done if the provided user is known by the identity component.
   * @param taskId task to claim, cannot be null.
   * @param userId user that claims the task. When userId is null the task is unclaimed,
   * assigned to no one.
   * @throws ActivitiException when the user or task doesn't exist or when the task
   * is already claimed by another user.
   */
  void claim(String taskId, String userId);

frankee787
Champ on-the-rise
Champ on-the-rise
The intention is to "Release" or "Unclaim" a task. Also it will be done by the same user alone. Hence what would be the ideal way to do it ?

Regards,
Franklin

frederikherema1
Star Contributor
Star Contributor
The javadoc states:

@param userId user that claims the task. When userId is null the task is unclaimed,
   * assigned to no one.

So use the claim(null) to 'unclaim' instead of the steAsisgnee(null).

frankee787
Champ on-the-rise
Champ on-the-rise
Thanks.

Will Do.

Regards,
Franklin