# Add a task listener to all UserTasks

**URL:** <https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814>\
**Category:** Flowable Engine\
**Created:** [September 23, 2020, 1:32pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814 "2020-09-23T13:32:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [September 23, 2020, 1:32pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814/1 "2020-09-23T13:32:23Z")

</div>

Hi

In our project - we are going to use our own logic and configuration to decide on the assignee or candidates for all UserTasks.

I wrote a Bean that can be used to return the list of users for a given task based on the taskDefId + a few additional parameters we set on the context and have in our configuration.

So far i have used it by setting the assignee/candidate on each UserTask as an expression that calls that method - and it works fine.

But in order to avoid the need to set it on each task - i wanted to add a task listener on all UserTasks - that will run on task create - and will call that logic and assign the values. This will save use setting the method on each task - give use flexibility (and avoid mistakes).

So i created my EngineConfigurationConfigurer - and in it i used setCustomDefaultBpmnParseHandlers  
to set my UserTaskBpmnParseHandler which extends UserTaskParseHandler.

But inside my handler - i could not manage to add a new execution listener. I tried using different examples - but still could not make it work ( i do arrive inside the handler - just no listener added).

UserTask as a method of getTaskListener - but it returns a list of FlowableListener (and not TaskListener) - and did not know how to use it to add my listener.

Am i using a correct approach for this task - or is there a better way to achieve that ?  
Is there any example i could use as reference on how to do that ?

Thanks  
Inbal

---

<div class="post-metadata">

**Author:** ![fiki574](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/fiki574/32/1675_2.png) [@fiki574](https://forum.flowable.org/u/fiki574)\
**Post date:** [September 23, 2020, 2:48pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814/2 "2020-09-23T14:48:30Z")

</div>

Hey.

I think you need to change the user task behaviour by defining your own UserTaskActivityBehavior implementation.

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [September 23, 2020, 2:52pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814/3 "2020-09-23T14:52:15Z")

</div>

Thanks for the fast reply - will have a look at that option.  
Do you know any example i can use as reference ?

---

<div class="post-metadata">

**Author:** ![fiki574](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/fiki574/32/1675_2.png) [@fiki574](https://forum.flowable.org/u/fiki574)\
**Post date:** [September 23, 2020, 3:07pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814/4 "2020-09-23T15:07:47Z")

</div>

Not sure, small description I found only here: [Starting With Flowable As Developer](https://forum.flowable.org/t/starting-with-flowable-as-developer/4927/4)

But for starterts, you need Spring Boot Flowable Engine in your application, and then you need to configure an appropriate bean which will be injected into the Engine. That’s all I know.

---

<div class="post-metadata">

**Author:** ![iadded](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@iadded](https://forum.flowable.org/u/iadded)\
**Post date:** [September 23, 2020, 3:31pm UTC](https://forum.flowable.org/t/add-a-task-listener-to-all-usertasks/6814/5 "2020-09-23T15:31:34Z")

</div>

Ok - i managed to make it work using my approach of adding a listener on the create event.  
In my UserTaskBpmnParseHandler i just created the FlowableListener (i used the FlowableListenerParser as a reference on how to set the fields) - and it works fine.  
My Handler is called on each create of a UserTask - and it sets the required Assignee/Candidates

Thanks for help on this  
Inbal
