# Getting execution listeners details for completed process instance

**URL:** <https://forum.flowable.org/t/getting-execution-listeners-details-for-completed-process-instance/7635>\
**Category:** Flowable Engine\
**Created:** [March 22, 2021, 1:02pm UTC](https://forum.flowable.org/t/getting-execution-listeners-details-for-completed-process-instance/7635 "2021-03-22T13:02:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akki](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@akki](https://forum.flowable.org/u/akki)\
**Post date:** [March 22, 2021, 1:02pm UTC](https://forum.flowable.org/t/getting-execution-listeners-details-for-completed-process-instance/7635/1 "2021-03-22T13:02:11Z")

</div>

Hi,  
I’m using below code for getting the above details before process is completed:

```
Process process = ProcessDefinitionUtil.getProcess( lFlowableProcessCancelledImpl.getProcessDefinitionId() );
process.getExecutionListeners() );

```

When I try this for already completed process instance, I get this error

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/b/b6f8055a3b61eb2dd584dc7212466b87480f2ec7.png)

So, I want to know if there is any way I can **retrieve execution listeners information for a completed process instance.**

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [March 29, 2021, 8:35am UTC](https://forum.flowable.org/t/getting-execution-listeners-details-for-completed-process-instance/7635/2 "2021-03-29T08:35:04Z")

</div>

Hey @akki,

The error is not coming because you are getting the execution listeners. It is coming because you are using an internal API `ProcessDefinitionUtil` outside of a command context.

The correct way to do this is to use the `RepositoryService`.

e.g.

```auto
Process process = repositoryService.getBpmnModel(definitionId).getMainProcess()

```

or

```auto
Process process = repositoryService.getBpmnModel(definitionId).getProcess(processDefinitionKey)

```

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![akki](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@akki](https://forum.flowable.org/u/akki)\
**Post date:** [April 2, 2021, 12:43pm UTC](https://forum.flowable.org/t/getting-execution-listeners-details-for-completed-process-instance/7635/3 "2021-04-02T12:43:56Z")

</div>

Hi @filiphr ,  
Thanks for your response.  
Yes, I’m able to get the process details with the code that you have shared but I don’t get the information from process that I was looking for.  
I will try to briefly explain my use case.

User wants to be notified if a process is canceled and he wants a screen where he can configure related fields as well. Something like this

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/1/13b4699fc3ae4a7747cce5679cbcb170bed71048.png)

There is an option to use the `Event Listeners` field in the stencil with id `BPMNDiagram`. But for now, I am using `Execution Listeners` `end` event since the user also wants a configurable screen like above.

So, when a user tries to cancel the process, I get the execution listener details from the `Process`, trigger cancel notification and set an empty arraylist in its `executionListeners` field. Also, I set an empty ArrayList to `executionListeners` field of `Process` when a process is completed, so that cancel notification is not sent when a process is completed. I do this when `PROCESS_COMPLETED` is dispatched.

The logic that you have shared fetches me the details if the process instance is not completed. But for a completed process instance, I get an empty list there.  
I’m assuming the reason is that I cleared `executionListeners` field in `PROCESS_COMPLETED` event.

To meet this, as of now I’m extracting execution listeners from `modelEditorJson` using `modelRepository.findByKeyAndType().get(0).getModelEditorJson();`  
Is there a better way to do this?
