Task instance id from Execution Listener

I have an Execution Listener (DelegateExecution) implemented and when I get execution event for Task type’s, I’d like to get instance id of that specific user task. Basically the same task instance id (or id) that can be seen when invoking REST API which gets active tasks for a given process instance id:

http:///engine-rest/task?processInstanceId=eafc9291-b2fa-11e9-a9d0-0242ac140002

I tried execution.getActivityInstanceId but it doesn’t seem to be the same id. My goal here is to get task instance id from execution so it can be later used to “auto-complete” task on behalf of user. The app would invoke complete task via REST API, but requires task instance id.

http://localhost:8081/engine-rest/task//complete

2 Likes

I would suggest using a Task Listener instead of an execution listener.
An Execution Listener is run before the task exists so there is not ID. But a task listener runs after a task is created so you can get the idea easily.

4 Likes

Thanks much!! This worked perfectly!!

1 Like

Can you share the codes for me brother. Like how did you implemented Task Listener.