Email Notification-Entity Log

Hi Team,
I have added one specific entity in the entity log from CUBA Administration. So whenever changes made by user related to the entity from the entity log ,at the time Email notification need to send for the particular user. How i can add email alert to entity log…



Do you really want to need an entity log facility? If you track changes for the specific entity, you can use EntityChangedEvent Listener. Have you considered it?

1 Like

Hi Andrey!
Yeah Andrey i need an entity log… Here my requirement is , For example i’m havin saas_Project Entity.
In saas_Project Entity if we made any changes means all the the changes will store in Entity log. In that Entity log ,We can fetch all the details like who changed , from which entity, what is the change type and attribute changes also, like old value and new value. So the thing is, whenever changes happen in an any entity, that record will be capture in entity log. That newly inserted record from entity log details i need to get, the whole record. This the thing i need…How i can get that…?

kannan Subramaniyam


I think you can achieve this by creating entity listener for EntityLogItem entity. I would start from implementing the interface com.haulmont.cuba.core.listener.AfterCompleteTransactionListener. As an example, you can have a look at class in CUBA framework.

1 Like

Hi Andrey!

Once after updating the Db we need to get log from EntityLogItem.

@TransactionalEventListener(phase = TransactionPhase.AFTER_COMPLETION)
    public void afterCompletion(EntityChangedEvent<EntityLogItem, UUID> event) throws Exception {
        if (event.getType().equals(EntityChangedEvent.Type.UPDATED)) {
            Project project = loadEntity(event);


    private void sendEmailNotification(Project project) throws EmailException {
        if (project.getProjectOwner() != null) {
            String email = project.getProjectOwner().getEmail();
            String templatePath = "com/company/saas/email/activityDetails.ftl";
            String caption = "Activity Log";
            sendEmailNotificationToOwner(email, templatePath, caption, project);


    private void sendEmailNotificationToOwner(String email, String templatePath, String caption, Project project) throws EmailException {

        EmailInfo emailInfo = EmailInfoBuilder.create()
                .setTemplateParameters(Collections.singletonMap("activity", project))

    private Project loadEntity(EntityChangedEvent<EntityLogItem, UUID> event) throws Exception {
        Project project = null;
        if (event.getType() != EntityChangedEvent.Type.UPDATED) {
            project = dataManager.load(LoadContext
                    .create(Project.class).setQuery(LoadContext.createQuery("select u from saas_Project u where =:id")
                            .setParameter("id", event.getEntityId()))
        return project;


The above code I have written to get access EntityLogItem entity. But once after updating the Db the above method doesn’t execute. So i can’t get details from EntityLogItem entity. What is the mistake i have made in my code…?

Hi Kannan.

I meant native CUBA listeners, not Spring transaction listeners. Since you cannot specify an additional listener to a system entity, you need to extend it and add a listener to the extended entity. Please have a look at the Entity Extension guide to understand the code. Please note that EntityLogItem is a system entity, so I had to extend the base table separately in 30.create-db.sql file:

alter table SEC_ENTITY_LOG add column DTYPE varchar(255) ^
update SEC_ENTITY_LOG set DTYPE = 'logger_TransactionalEntityLogItem' where DTYPE is null ^

The example is attached. Do not forget to enable entity logging for the Test entity in the application. (102.7 KB)

1 Like

Thanks a lot Andrey…