cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve CandidateGroup for a task

aurelienpel
Champ in-the-making
Champ in-the-making
Hello,

When I create a workflow with Activiti Explorer, I give for a task a candidateGroup, I can see it when I edit the bpmn20.xml : <userTask id="development" name="Development" activiti:candidateGroups="DEVELOPER.ITSM">

However, when I retrieve a specifc task with the REST API call : GET runtime/tasks/{taskId}   I can't find the candidateGroup.

Also, how can it be retrieved in the generated diagram ? This is to know who can claim a task.

Thanks

Aurelien
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
No, nor will the Java API give you the candidate group if you ask it. It works the other way around: you ask which tasks match a certain candidate group/

To get insight into which group was set in the process definition, you need to use the method on the repositoryService that returns a BpmnModel. That is a POJO representation of the process xml that contains that information.

aurelienpel
Champ in-the-making
Champ in-the-making
May you give me this method please ?

I tried with
<code>
List<String> candidateGroup =
         ProcessEngines
.getDefaultProcessEngine()
.getRepositoryService()
.getBpmnModel(processDefinitionId)
.getMainProcess()
.getCandidateStarterGroups();
</code>
but the result is null

or
<code>
processDefinition =
(ProcessDefinitionEntity)
((RepositoryServiceImpl) ProcessEngines
   .getDefaultProcessEngine()
   .getRepositoryService())
   .getDeployedProcessDefinition(processDefinitionId);

for (ActivityImpl activity : processDefinition.getActivities()) {
if("userTask".equals((String) activity.getProperty("type"))){
  // I can get the correct info
  (String) activity.getProperty("name");
  (String) activity.getProperty("documentation");
  (String) activity.getId();
  // next line is empty
  (String) activity.getProperty("assignments");
 
}
}
</code>
isn't it thanks to the property 'assignments' ?

Thanks for your help !

Regards

trademak
Star Contributor
Star Contributor
When you get the BpmnModel you should get the task flow element first and then get the candidate group from the found UserTask. So you shouldn't check for the candidate starter groups on a process level.

Best regards,