Setup Candidate Users does not work

Hi,

I am new to Camunda.
I tried to setup candidate users, however it does not work.

Task

<bpmn2:userTask id="validation4" name="Validation_4" camunda:assignee="${assignee3}" camunda:candidateUsers="${assignee3Candidate}">
  <bpmn2:incoming>SequenceFlow_0djfbs5</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_0i7jzef</bpmn2:outgoing>
</bpmn2:userTask>

I have tried the following options :
List candidateUsers = [ ‘chef1’, ‘chef2’, ‘chef3’] as String[];
runtimeService.setVariable(executionId, “assignee3Candidate”, candidateUsers)
and this one
runtimeService.setVariable(executionId, “assignee3Candidate”, “chef1, chef2, chef3”)

But none of them work, I got and empty list when I make a query:
def taskCandidateList = taskService.createTaskQuery().taskCandidateUser(“chef1”).list()

Thank you for your help.

Regards,

Alioune

Hi @abadiane,

When is this runtimeService.setVariable(executionId, "assignee3Candidate", candidateUsers) executed? Before the user task is created or after the task has been created?

Cheers,
Roman

Hi Roman,

I run the setVariable before completing the current task.
So I suppose that it is before the task has been created. In fact I want to use the variable assignee3Candidate in the next task of the process.

        **runtimeService.setVariable(executionId, "assignee3", "directeur3")**

** List candidateUsers = [ ‘chef1’, ‘chef2’, ‘chef3’] as String[];**
** runtimeService.setVariable(executionId, “assignee3Candidate”, candidateUsers)**

** taskService.complete(params.taskId)**

Regards,

Alioune.

Hi @abadiane,

Could you please share your code or a failing test case? This would make it easier to understand what is actually happen.

BTW, is the passed executionId the process instance id?

Thanks.

Cheers,
Roman

parallele_gateway_withCandidateUsers.bpmn (11.3 KB)

Hi Roman,

Thak you for your help.
You will find attached the grails controller.
The methods to check are saveValidation and index

Regards,

Alioune.

Hi Roman,

The bpm process.

Regards,

Alioune.parallele_gateway_withCandidateUsers.bpmn (11.3 KB)

ProcessBPMController.groovy.txt (10.8 KB)

Attached please find the grails controller.

Regards,

Alioune.

In which state is the process instance (i.e. which tasks are active), when saveValidation is executed?

Cheers,
Roman

Hi Roman,

Please find attached the ACT_RU_TASK content.
The SUSPENSION_STATE_ is equal 1.
ACT_RU_TASK.csv (917 Bytes)

Regards,

Alioune

Hi @abadiane,

I am very sorry, but I am not able to follow you.

Could you please describe step by step what are you doing? And during which step is the method saveValidation called.

Cheers,
Roman

Hi Roman,

Please find below the steps :

  • agent1 initiate the process, and create the task “initialisation” (methods ‘create’ and ‘save’). The task “initialisation” is completed in the save method. The next task “validation1” is assigned to chef1
    status => OK

  • chef1 process the task “validation1” (methods ‘validation’ and ‘saveValidation’). The task “validation1” is completed in this step, and the parallel tasks are created for “directeur1”, “directeur2”,“directeur3”

  • The three tasks are created with success however the assignee3Candidate that was setup before the “validation1” task is completed does not work.

the taskCandidateList = taskService.createTaskQuery().taskCandidateUser(“chef1”).list() returns an empty list

Thank you for your help.

Regards,

Alioune.

Hi @abadiane,

I had a look into the query.

When you execute

 taskService.createTaskQuery().taskCandidateUser("chef1").list()

then the query checks also that the assignee is null for these tasks.

In your case the task Validation_4 has also an assignee, so that this task is not returned when you execute the query. To solve that you could use additionally the query parameter includeAssignedTasks(), which would look as follows:

 taskService.createTaskQuery().taskCandidateUser("chef1").includeAssignedTasks().list()

Note that you have to call taskCandidateUser() before you can execute includeAssignedTasks().

Does it help you?

Cheers,
Roman

1 Like

Hi Roman,

Thank you very much, that was the issue.
It works fine now.

Regards,

Alioune.