How to get unique ID of current serviceTask execution in java delegate class?

is there a way how to get unique id of current serviceTask execution in java execute method (my class implements JavaDelegate interface)? I spent a lot of time to find it but unsucessfuly.

Reason why I need it is, that I will have a loop and inside it serviceTask will be executed. I would like to get unique ID of this serviceTask and use it in a map (flow variable) where it will be as a key. In value I will store other data related to this particular serviceTask execution.

There is a table where this ID is present. Table name is “ACT_HI_ACTINST” and column I need is “ID_”.

However I am not able to get it in the current execution method of my delegate class.
I am able to get ids of previous finished activities by calling:


This will return list of ActivityInstanceEntity objects and their id is what I am looking for. But there are only finished acitivities.

I tried to use this query above in onEnd listener, but serviceTask the listener is attached to is still not there.

During debugging I went through whole DelegateExecution object which is input param into execution method, but I could not find it there. There is for example “EXECUTION_ID_” from above table, but it is not unique as you can see. During debug (when stopped on a breakpoint) I also checked tables “ACT_RU_ACTINST” and “ACT_HI_ACTINST”, but record for currently executed serviceTask is not yet there.

Is there any way how can I obtain it? If not do you have an idea how can I store data related to each particular serviceTask execution? But I need to know to which one exactly it belongs to. Because I am sending then this info to FE to render it.
For this reason I use:


And these data should be extended by my custom info.

Something like this I will use for defining serviceTask:

<serviceTask id="createCards" name="Create Cards" flowable:delegateExpression="${addCardDelegate}">