I have a requirement where I need to auto delegate a task to a delegatee. The business requirement is to verify in the DB and find out who are the valid delegatees for the current delegator(actorId) for the current duration.
On node trigger event we need to check for the valid delegatee and auto assign/delegate this user to the task. We know that Jbpm allows us to do the delegation explicitly using delegate() method.
We have the valid delegatee information from DB at the time of node triggered but inorder to delegate the task we need to have the taskId information which is not available in this node trigger event. This is because, task object might not have been created yet.
public void delegate(taskId, userId, targetUserId)
We can't even use taskClaimed event method because it is not getting triggerd in case where there is single actorId specified for the node(in bpmn). It is because Jbpm directly moves the node from task 'Created' to 'Reserved' status in this case.
public void taskClaimed(TaskClaimedEvent event)
So, I dont have any idea, how to implement our requirement. Please help us.
One approach could be to copy SyncWSHumanTaskHandler (Jboss source) class and adding our logic to handle auto delegation. In this class method(executeWorkItem()) you are given with taskId, actorId, groupId details using which we can write the delegation logic.