# getExecution() not available on DelegateTask interface, what to use instead?

**URL:** <https://forum.flowable.org/t/getexecution-not-available-on-delegatetask-interface-what-to-use-instead/9694>\
**Category:** Flowable Engine\
**Created:** [September 1, 2022, 10:04am UTC](https://forum.flowable.org/t/getexecution-not-available-on-delegatetask-interface-what-to-use-instead/9694 "2022-09-01T10:04:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalmytnik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/michalmytnik/32/2918_2.png) [@michalmytnik](https://forum.flowable.org/u/michalmytnik)\
**Post date:** [September 1, 2022, 10:04am UTC](https://forum.flowable.org/t/getexecution-not-available-on-delegatetask-interface-what-to-use-instead/9694/1 "2022-09-01T10:04:13Z")

</div>

Hello, I’m working on upgrade from Activiti version 5.2.2 into Flowable 6.7.2. There was quite a lot occurances in the system of such mechanism:

class AnyClass implements TaskListener{  
…  
@Override  
public void notify(DelegateTask delegateTask){  
**DelegateExecution execution = delegateTask.getExecution();**

// many actions performed on the execution…  
}  
}

Unfortunately DelegateTask interface has been modified quite a long time ago, and there is not getExecution() method available anymore, I could find getExecutionId() instead, but I’m not sure what would be the correct way of capturing the Execution or preferable DelegateExecution, don’t know which Service will provide such with the same capabilities like that older implementation had. Could you please advise on that? I need to be careful with that changes to leave the system stable after the upgrade. Thanks!

---

<div class="post-metadata">

**Author:** ![gdharley](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/gdharley/32/2695_2.png) [@gdharley](https://forum.flowable.org/u/gdharley)\
**Post date:** [September 1, 2022, 7:16pm UTC](https://forum.flowable.org/t/getexecution-not-available-on-delegatetask-interface-what-to-use-instead/9694/2 "2022-09-01T19:16:53Z")

</div>

Hi Michael,  
Yes, lots has changes from when Activiti 5.2 was released.  
I’m not sure exactly what “many actions performed on the execution” really entails but there may be easier ways to achieve your goals now.  
That said, you can get the execution from the RuntimeService using an execution query:

```
    RuntimeService rs = ProcessEngines.getDefaultProcessEngine().getRuntimeService();
    Execution ex = rs.createExecutionQuery().executionId(task.getExecutionId()).singleResult();

```

Again, not sure if refactoring is better or not, but at least this should move you forward.

---

<div class="post-metadata">

**Author:** ![michalmytnik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/michalmytnik/32/2918_2.png) [@michalmytnik](https://forum.flowable.org/u/michalmytnik)\
**Post date:** [September 4, 2022, 3:41pm UTC](https://forum.flowable.org/t/getexecution-not-available-on-delegatetask-interface-what-to-use-instead/9694/3 "2022-09-04T15:41:26Z")

</div>

Thank you, that definitely helps!
