cancel
Showing results for 
Search instead for 
Did you mean: 

Basic concepts about users and tasks

andregs
Champ in-the-making
Champ in-the-making
Hi,

Could you please explain the different relationships between users and tasks?
- Owner
- Assignee
- Candidate
- Involved

I also don't understand the difference between reassign, transfer and delegate a task.

Related topics:
- http://forums.activiti.org/en/viewtopic.php?f=6&t=2043
- http://forums.activiti.org/en/viewtopic.php?f=6&t=2237

Thanks,
12 REPLIES 12

heymjo
Champ on-the-rise
Champ on-the-rise
Yes, this would be helpful.

http://forums.activiti.org/en/viewtopic.php?f=9&t=2246 is also relevant (explains Queued Tasks which is not an API semantic but appears in the Explorer)

mhw
Champ in-the-making
Champ in-the-making
Hi,

I am very interested, too. I do not understand why activiti:candidateUsers="accountancyUser" does not lead to List<Task> myTasks =
                processEngine.getTaskService().createTaskQuery().processDefinitionId(processInstance.getId())
                        .taskCandidateUser("accountancyUser").list();
beeing a list with more than zero elements.

regards, Michael

trademak
Star Contributor
Star Contributor
Hi,

- An owner is the user that's responsible for the user task. You can have multiple sub tasks, but there's one user, the owner, who is responsible for the task.
- As assignee is a user that's allocated to that user task, and needs to complete it.
- A candidate user is a user that can claim the user task to become the assignee. Note that there's no built-in authorization that somebody who isn't a candidate user can't claim a user task and become the assignee.
- A candidate group is a group of users that can claim the user task to become the assignee.
- An involved user is somebody that's linked to the user task. You can have only 1 assignee, but you have multiple users who can be involved in the user task.

Queued tasks are user tasks that don't have an assignee, but only candidate users / groups.

The taskCandidateUser query option should return user tasks that have been configured with activiti:candidateUsers="accountancyUser".
If it's not working please post your implementation with a test case so we can reproduce it.

Best regards,

heymjo
Champ on-the-rise
Champ on-the-rise
So owner and involved user are just implicit concepts that have no runtime meaning in the process definition ? If so then it is strange to see these things being so prominent in the api and explorer. It gives impression that they are first class concepts of bpmn modelling but when you turn to the process definition they are nowhere to be seen. I think that is where much of the confusion came from.

(also what about the transfer / reassign / delegate part?)

trademak
Star Contributor
Star Contributor
Hi,

Yes they are implicit concepts. I don't understand your comment about them being so prominent in the API.
Of course they are available in the API, otherwise you couldn't use them. And for a process or case management solution these concepts can be very important.
But I can understand the concepts are a bit confusing. We may need to add some explanation in the user guide.

Transfer and reassign are pretty much the same thing. Setting a new owner is called a transfer, and setting a new assignee is called a reassign.
When you delegate a task as an owner, an assignee can work on the task and resolve it. When the assignee resolves it, the task is assigned back again to the owner.

Best regards,

heymjo
Champ on-the-rise
Champ on-the-rise
well with "prominent" i meant that there is an Involved tab in the explorer and there is an api method called TaskQuery.involvedUser, whereas the Involved notion until 5.7 was not really documented.

Thanks for clearing things up though, a few more lines in the doc would be helpful indeed.

mhw
Champ in-the-making
Champ in-the-making
Hi,

thank you for the detailed explanation. Now I have a much better understanding. Unfortunately I am not able to get my process running as expected.
<definitions id="definitions"
             targetNamespace="http://activiti.org/bpmn20"
             xmlns:activiti="http://activiti.org/bpmn"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">

  <process id="assigningRoles">

    <startEvent id="begin"/>

    <sequenceFlow id="flow1" sourceRef="begin" targetRef="createReport"/>

    <userTask id="createReport" name="create the report" activiti:candidateUsers="accountancyUser"/>

    <sequenceFlow id="flow2" sourceRef="createReport" targetRef="verifyReport"/>

    <userTask id="verifyReport" name="verify the report" activiti:candidateUsers="accountancyUser"/>

    <sequenceFlow id="flow3" sourceRef="verifyReport" targetRef="end"/>

    <endEvent id="end"/>

  </process>

</definitions>


  // create a test user in group ROLE_EDIT
  User accountancyUser = identityService.newUser("accountancyUser");
  Group accountancyGroup = identityService.newGroup("ROLE_EDIT");
  identityService.saveGroup(accountancyGroup);
  identityService.saveUser(accountancyUser);
  identityService.createMembership(accountancyUser.getId(),
    accountancyGroup.getId());

  List<Group> groups = identityService.createGroupQuery()
    .groupId("ROLE_EDIT").list();
  assertEquals(1, groups.size());

  List<User> users = identityService.createUserQuery()
    .memberOfGroup("ROLE_EDIT").list();
  assertEquals(1, users.size());

  accountancyUser = users.get(0);
  assertEquals("accountancyUser", accountancyUser.getId());

  // start the process
  ProcessInstance processInstance = runtimeService
    .startProcessInstanceByKey("assigningRoles");

  // "accountancyUser" should have one task after the process instance was
  // created
  List<Task> myTasks = processEngine.getTaskService().createTaskQuery()
    .processDefinitionId(processInstance.getId())
    .taskCandidateUser("accountancyUser").list();
  Assert.assertNotNull(myTasks);
// here the test fails:
  Assert.assertEquals(1, myTasks.size());

  // now see if he's involved user on any task of the the process instance
  Assert.assertTrue(processEngine.getTaskService().createTaskQuery()
    .processDefinitionId(processInstance.getId())
    .taskInvolvedUser("accountancyUser").list().size() == 0);

  // now add myself to the task as candidate user
  processEngine.getTaskService().addCandidateUser(myTasks.get(0).getId(),
    "accountancyUser");

  // and now all of a sudden i'm involved user on the task
  Assert.assertTrue(processEngine.getTaskService().createTaskQuery()
    .processDefinitionId(processInstance.getId())
    .taskInvolvedUser("accountancyUser").list().size() == 1);
}

What am I doing wrong?

best regards,
Michael

frederikherema1
Star Contributor
Star Contributor
The ID of the process-defintion is not the same as the one of the instance (line

processDefinitionId(processInstance.getId()) // "accountancyUser" should have one task after the process instance was
      // created
      List<Task> myTasks = processEngine.getTaskService().createTaskQuery()
            .processDefinitionId(processInstance.getId())
            .taskCandidateUser("accountancyUser").list();

mhw
Champ in-the-making
Champ in-the-making
Wow! Thank you for the lightspeed support. Works perfectly now, just took the processInstance.getProcessDefinitionId()So I have understood the roles concept  Smiley Very Happy

best regards,
Michael