Unable to Set Candidate User or Group

Hi,

I’m trying to dynamically set the user(s) that can claim a task. I’ve written a Task Listener that is invoked on create that programmatically sets the user:

<bpmn:userTask id=“Task_08ytsyj” name=“State 1” camunda:formKey=“embedded:app:forms/approve-loan.html”>
bpmn:extensionElements
<camunda:taskListener class=“com.myco.bpm.SetAuthorizedApproversTaskListener” event=“create” />
</bpmn:extensionElements>
bpmn:incomingSequenceFlow_1j4f7vc</bpmn:incoming>
bpmn:outgoingSequenceFlow_0z324z2</bpmn:outgoing>
</bpmn:userTask>

public class SetAuthorizedApproversTaskListener implements TaskListener {

public void notify(DelegateTask delegateTask) {

    UserTask userTask = delegateTask.getBpmnModelElementInstance();

             List<String> candidateUsers = new ArrayList<String>();
	candidateUsers.add("buser1");
	
	userTask.setCamundaCandidateUsersList(candidateUsers);
	
	userTask.setCamundaCandidateGroups("accounting");
	System.out.println("Assigned BUSER1");
	System.out.println("Assigned Accounting");
	//Input from Modeler

I start the process and the ‘demo’ user can claim the task which is not the behavior I want. I would expect that only BUSER1 can claim the task. Can someone help guide me here?

Thanks!

mkc

Hello,

Have you changed the default groups? Because demo is part of the accounting group and also of the admin.
I think that’s the reason behind this. Probably you can create a new admin user and reduce the permissions of demo user for you scenario.

Best regards,
Yana