cancel
Showing results for 
Search instead for 
Did you mean: 

How to use taskCandidateGroup, taskCandidateUser?

x1957
Champ in-the-making
Champ in-the-making
Hi all,

I'm the beginner of activiti, I'm trying to write some simple code to understand the APIs.

    Task task1 = taskService.newTask();
    Task task2 = taskService.newTask();
    Task task3 = taskService.newTask();
     
    task1.setName("task1");
    task2.setName("task1");
    task3.setName("task3");
    taskService.saveTask(task1);
    taskService.saveTask(task2);
    taskService.saveTask(task3);
   
    Group group1 = identityService.newGroup("group1");
    Group group2 = identityService.newGroup("group2");
    identityService.saveGroup(group1);
    identityService.saveGroup(group2);

    User user1 = identityService.newUser("user1");
    User user2 = identityService.newUser("user2");
    identityService.saveUser(user1);
    identityService.saveUser(user2);
   
    taskService.addCandidateUser(task1.getId(), user1.getId());
    taskService.addCandidateUser(task2.getId(), user1.getId());
    taskService.addCandidateUser(task3.getId(), user2.getId());
   
    identityService.createMembership(user1.getId(), group1.getId());
    identityService.createMembership(user2.getId(), group2.getId());
   
    taskService.addCandidateGroup(task1.getId(), group1.getId());
    taskService.addCandidateGroup(task2.getId(), group1.getId());
    taskService.addCandidateGroup(task3.getId(), group2.getId());

    List<Tasks> tasks = taskService.createTaskQuery().taskCandidateUser(user1.getId()); // size 0
    tasks = taskService.createTaskQuery().taskCandidateGroup(group1.getId()); // size 0

Why I got empty in this two query? How to use taskCandidateGroup, taskCandidateUser?
1 REPLY 1

x1957
Champ in-the-making
Champ in-the-making
I have found the answer.
The task must not be assgined.