cancel
Showing results for 
Search instead for 
Did you mean: 

DelegateTask through TaskService

dharmesh
Champ in-the-making
Champ in-the-making
Hi,

I need permissions stored in XML as activiti:candidateGroup into my code.

Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskDefinitionKey(taskId).singleResult();
String permissionName = ((DelegateTask)task).getCandidates().iterator().next().getGroupId();

Above throws NullPointer at getIdentityLinks in TaskEntity.

java.lang.NullPointerException
   at org.activiti.engine.impl.persistence.entity.TaskEntity.getIdentityLinks(TaskEntity.java:449)
   at org.activiti.engine.impl.persistence.entity.TaskEntity.getCandidates(TaskEntity.java:391)

Thanks
3 REPLIES 3

trademak
Star Contributor
Star Contributor
You can retrieve the identity links via the task service getIdentityLinksForTask method.
Your example is not the supported way to retrieve candidates or identity links.

Best regards,

dharmesh
Champ in-the-making
Champ in-the-making
Is there any way I can get candidates if tasks are not active?
Can parsing help?

ProcessDefinitionEntity processDefinitionE = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());

trademak
Star Contributor
Star Contributor
To get the candidates defined in the process definition, the easiest way is to use to getBpmnModel method on the RepositoryService interface. It will give back a Java POJO model of the process definition and you can lookup the user task and assignment definition.

Best regards,