Get user who completed a specific task programmatically

How can I get the username that completed a specific task programmatically?

In my JavaServiceTask, I have two objects: DelegateExecution and RuntimeService, but I haven’t figure out how to play with them to get a task by Id from the current process instance, and for that task, get the assignee or user who completed the task.



DelegateExecution class has a method getProcessInstanceId through which you can get the current processInstanceId of this execution (Doc : Using this processInstanceId you can use History Service to create a Historic Task Instance Query (Docs :

then you can use taskDefinitionKey you declared in flowable-modeler to find the task you are looking for. Once you have the
object of HistoricTaskInstance, you can find anything about that task like taskId, Assignee etc.
Your query might look like this :
“historyService.createHistoricTaskInstanceQuery().taskDefinitionKey(“dummyTaskKey”).singleResult()” . This will return you HistoricTaskInstance class object. Then you can use functions associated with this object to get the required things.

Thank You,

1 Like