MailMessage Event Observer

Hi All

I wrote this event observer to intercept everywhere the user create a post mail message (Timesheet, Leave, ExtraHours, Expenses etc…)

It doesn’t works.

`` void onPostSavingMailMessage( @Observes @Priority(0) @EntityType(MailMessage.class) @Named(RequestEvent.SAVE)
PostRequest event) {

Any idea?
Thanks

have you tried the on Persist observer of entity listener ?

I didn’t because I have to modify MailMessage.xml file of axelor-core.

please try, you need to catch the main model rather individual message interception

How Can I override it?
This xml file axelor-core/src/main/resources/domains/Mail.xml
I want avoid to change the domain in the core.

you can add the file in any module, and you should create new module and add file and just add lines related to entity listener

<entity name="Contact">
  ...
  <entity-listener class="com.axelor.contact.db.repo.ContactListener"/>
</entity>
1 Like

Good idea! will try and let you know! Thanks @siddique

Hi @siddique

I’m trying to override the MailMessage in order to add the Listener.

Then I get this errors.

Any idea?

@femtonext
Any help with this?