cancel
Showing results for 
Search instead for 
Did you mean: 

Taks list

alfa
Champ in-the-making
Champ in-the-making
How obtain all tasks in a process for list when process is instanciate?

By example, my process "Test" desing is:
task1->task2->task3
I instanciated the process:

String procId = runtimeService.startProcessInstanceByKey("Test").getId();

I can obtain the list tasks actives:

List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("Prorroga").list();

but, How I can obtain all pendings tasks my process "Test"?

Cheers,
1 REPLY 1

sangv
Champ in-the-making
Champ in-the-making
Well I am no expert but if you mean user tasks by pending tasks, you can use this API:

List<Task> taskList = taskService.createTaskQuery().taskCandidateUser("accountancyUser1").list();
  assertEquals(2, taskList.size());

Ofcourse, this assume that you tied the accountancyGroup as the owner of your user task.

<userTask id="writeReportTask" name="Write monthly financial report" >
            <documentation>
              Write monthly financial report for publication to shareholders.
            </documentation>
            <potentialOwner>
              <resourceAssignmentExpression>
                <formalExpression>accountancyGroup</formalExpression>
              </resourceAssignmentExpression>
            </potentialOwner>
          </userTask>

I also had this in my setup:

User accountancyUser1 = identityService.newUser("accountancyUser1");
  identityService.saveUser(accountancyUser1);

  Group accountancyGroup = identityService.newGroup("accountancyGroup");
  identityService.saveGroup(accountancyGroup);

  identityService.createMembership(accountancyUser1.getId(), accountancyGroup.getId());

  List<User> accountancyGroupUsers = identityService.createUserQuery().memberOfGroup(accountancyGroup.getId())
    .list();
  assertTrue(accountancyUser1.getId().equals(accountancyGroupUsers.get(0).getId()));

Thanks,
Sang