In Service Task how can I get user id of the user who completed previous user task?

In Service Task how can I get user id of the user who completed previous user task?
Thanks

1 Like

If the service task runs in the same transaction as completing the user task and if the user has been made known to the Flowable Engine (IdentityService setAuthenticatedUserId), you can get the user with Authentication.getAuthenticatedUserId. When the service task runs in a new database transaction, you can query the HistoryService.createHistoricTaskInstanceQuery to get the completed task info, including the user id of the user that completed the task.

Best regards,

Tijs

1 Like

Hi tijs,

Can you tell me in which column of ACT_HI_TASKINST, it is stored who completed the task? Is the ASSIGNEE_ column contains the user who completed the task? I don’t know if i am right or wrong, but i am guessing any user can complete the task using taskService.complete() whether he is assignee of the task or not. Do we explicitly have to keep check that only assignee can complete the task.

Thank You,
Arpit

The assignee column will have the id of the task assignee, so not the authenticated user.
Flowable does not do any checks on the current user (which is an optional concept) and the task assignee being the same, you have to do this in the logic you have around that .complete() call.