How to find out candidate users of a task

Hi

I’m using the taskService to select all tasks of a specific user, e.g.

List taskList = taskService.createTaskQuery().taskCandidateUser(“Kermit”).list();

Additionally I want to show the corresponding candidate users for each task of this tasklist.
How can I do this?

Thanks and best regards,
Roland

1 Like

You can use

List getIdentityLinksForTask(String taskId);

method of task service.

All IdentityLinks which have getUserId() !=null and getType() == “candidate” are candidate Users.

Best regards

1 Like

That’s my piece of code to get the information:
List<IdentityLink> identities = this.taskService.getIdentityLinksForTask( task.getId() ); for ( IdentityLink identity : identities ) { String type = identity.getType(); switch ( type ) { case IdentityLinkType.ASSIGNEE: break; case IdentityLinkType.CANDIDATE: if ( identity.getGroupId() != null ) { camundaTask.setCandidateGroup( identity.getGroupId() ); } if ( identity.getUserId() != null ) { camundaTask.setCandidateUser( identity.getUserId() ); } break; case IdentityLinkType.OWNER: break; default : break; } }

1 Like

@Roland this is piece of my code for fetching candidate users by task identifier:

String candidateUsers = identityLinks.stream()
.filter(identityLink → identityLink.getType().equals(IdentityLinkType.CANDIDATE))
.map(IdentityLink::getUserId)
.collect(Collectors.joining(“,”));