Refreshing candidate users

I am currently setting the candidate users on a user task using a service bean
From what I understand, when the workflow reaches that task, the code is run and the candidate users are populated on the task. These candidates are stored in the DB and so for example when the workflow reaches this task, the code will run and [user1, user2] will be returned.
Now the task is open and waiting for one of those users to claim it and work on it.
But what if, between the time when the candidates were populated and the time when a user began working, another user was added to the DB - so now the method getApprovers would return [user1, user2, user3]. How is possible to refresh the candidates on a task so that user3 is also a candidate?

Hi @c_schon,

Setting candidate users for a running user task can be done through the method addCandidateUser(<TASK_ID>, <USER_ID>)

Timeout tasklistener can be utilized to retrieve your approvers periodically and accordingly call this method (example: every 15 mins) while the task is running.

1 Like

Hi @hassang,

Thanks for your reply!
Since I would like the refresh to happen automatically in the BE, then your second suggestion is great option. From what I understand, I can call a Java class which will call the method addCandidateUser(<TASK_ID>, <USER_ID>). However, at runtime, how can I know the taskId?
If I use a delegate, then in the DelegateExecution I can see the method getCurrentActivityId which can be useful, but this is the activityId and not the taskId

Thank you

Hi @c_schon,

Implementing TaskListener interface requires implementation of the method notify which has an instance of DelegateTask through which you can get task Id

notify(DelegateTask delegateTask)

1 Like

perfect, thank you for your help!