I'm modeling a process at a given time and want to assign a User Task to the user who created the instance of the process.
What should I put in my User Task "Assignee" field?
Thank you in advance
I'm modeling a process at a given time and want to assign a User Task to the user who created the instance of the process.
What should I put in my User Task "Assignee" field?
Thank you in advance
We solve this by setting a "startedBy" process variable on process start. Then, just use the variable value in the Assignee field: ${startedBy}.
You will have to modify your process start to get the logged in user. This can either be done by passing the variable to the "startProcessByKey" ... method or implementing a Listener on the start event that tries to get the user from the current session.
end listener on the start event works fine:
<camunda:executionListener expression="${execution.setVariable('startedBy', authenticatedUserId)}" event="end" />
We can set the process initiator through IdentityService.
public void test(){
//start process
identityService.setAuthenticatedUserId(userId);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinitionId);
//query
historyService.createHistoricProcessInstanceQuery().startedBy(userId).list()
}