Create Task and assign to CandidateGroup

Hi.

I’ve just started using Flowable and I’m still working through the tutorials so apologies in advance if I’ve missed something obvious.

Using the BPMN editor example (“holiday Request”) I see that a userTask (the “Approve or Reject Request”) in the flow definition is assigned to a candidateGroup called “managers”.

<userTask id="approveTask" name="Approve or reject request" flowable:candidateGroups="managers"></userTask>

If I instantiate an instance of the process and invoke the following code I get the task returned OK:

taskService.createTaskQuery().taskCandidateGroup(group).list();

The issue is when I try to create a new task manually, and get it assigned to the same “managers” candidateGroup using the API.

Task task = taskService.newTask();

The only relevant options I can see on the “task” variable are “setOwner” and “setAssignee”, neither of which have the task returned in the list above if I set the values to “managers”.

Is there a way to create a task manually via the API and have it work in a similar fashion to the XML definition?

Thanks in advance
Steve

Hi Steve,

use taskService to add candidate user/group to the task.

        task = taskService.newTask();
        task.setName("test");
        taskService.saveTask(task);

        taskService.addCandidateGroup(task.getId(), "sales");
        taskService.addCandidateUser(task.getId(), "kermit");

Regards
Martin

Hi Martin

That worked a treat - thanks very much for your quick assistance!

Kind regards
Steve