Query on delegate task addCandidateUsers

Trying to rewrite our existing product using Camunda. We have a requirement for dynamically assigning a task and to enable that we implement a tasklistener and on the delegatetask call addCandidateUsers. However, the assignments do not seem to work. setAssignee works and addCandidateGroups works. The process diagram for the inflight process shows no assignees when addCandidateUsers is used. Any help would be appreciated.

Both users are assigned to the manager group that has ALL permissions on all (*) ResourceID s

public class AssignmentCreateListener implements TaskListener {

@Override
public void notify(DelegateTask delegateTask) {	
		
            //will be swapped with custom logic 
	List<String> userNames = new ArrayList<String>();
	userNames.add("john");
	userNames.add("demo");

	//does not work 
	delegateTask.addCandidateUsers(userNames);
            
             // addCandidateGroup and setAssignee works
	//delegateTask.addCandidateGroup("managers");
	//delegateTask.setAssignee("demo");

            // addCandidateUser does not work as well.
	delegateTask.addCandidateUser("demo");


	
	
}

}

Hi @ksn
What did you mean by no assignee?
Setting candidate users or candidate user will keep assignee null until one of candidate users claims the task.

Hi @hassang - I meant the task does not appear on anyone’s task list to claim. In the above examples, users demo, john etc do not see the task at all once the process is kickstarted. (even if we click All tasks after logging in as the respective user). Are we missing something here? I would like to have a set of users be able to claim the approval task on the process after logging in. The issue is they don’t see the task at all.

Hi @ksn,

From cockpit, Try to do the following

  • Select the active process instance
  • Select the tab “User Tasks”
  • From action column, Select “manage users for your task”

Do you see your candidate users listed there?

1 Like

Hi @hassang,

Yes. When I select user tasks I can see the candidate users listed there. Per the example code I have given above - In the demo user I can see the task listed under all tasks. But user john does not have the ability to see all tasks? Also, when I click on John’s tasks from the demo user login that does not show me the task either. Is there something I am missing in the permission set?

Hi @ksn
You need to create a new filter to displays all tasks that have not yet been claimed and specify which users or groups can see the filter

See “Unassigned tasks” filter from below link
https://docs.camunda.org/manual/7.6/webapps/tasklist/filters/#common-filters

1 Like

Hi @hassang, Thanks! I created a filter with Candidate User = ${ currentUser() }. Works like a charm. Thanks.
Probably a nitpick but wondering if it would not be better this filter exists on default installation so users could see tasks that they could potentially claim. Thanks again for your help.