How to ensure that two different human task of a process have same user as assignee

Hi all,

We have a process having four human tasks. Our second and forth human tasks are offered the same candidate group. Our business logic requires that assignee of the forth human task must be same with the user who completed the second human task? Is there any way to realize this?

Thanks

Yes - use a task listener to store who completed the task in a process variable, in the below example i’m using a Java Class

import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;

public class GetCompleteUser implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
        
        String userName = delegateTask.getAssignee();
        delegateTask.setVariable("userName", userName);
        
    }
}

Then use an expression on the assignee field in the modeler which sets the assignee at runtime.