I have been researching how popup notifications are generated in Espo.
For participants also interested in customizing popup notifications, this is the program flow as I understand it:
Periodic notifications:
Activity reminders:
Data structure of the list of pending popup notifications:
Please note that this is NOT an official guide by any means. These are my notes and observations about the notifications mechanism at Espo, so there might be errors. Please feel free to add or modify as necessary any information that might be inaccurate or incomplete.
I will post more information as I learn more about this subject.
For participants also interested in customizing popup notifications, this is the program flow as I understand it:
Periodic notifications:
Script | Function / Method | Notes |
application/Espo/Modules/Crm/Jobs/SubmitPopupReminders.php | run() | builds a list of pending popup reminders to be displayed and uses a webhook to trigger a popupNotifications event for the current user |
application/Espo/Modules/Crm/Resources/metadata/app/popupNotifications.json | popupNotifications metadata file, contains the url for the back-end controller that retrieves reminders associated with activities and specifies the view which will actually render the notification in the screen. | |
client/modules/crm/src/views/meeting/popup-notification.js | init() | method inherited from client/src/views/popup-notification.js sets the basic functionality of the popup display and loads the information for one notification |
client/modules/crm/src/views/meeting/popup-notification.js | data() | sends the placeholder data to the template client/modules/crm/res/templates/meeting/popup-notification.tpl to render the notification. |
Activity reminders:
Script | Function / Method | Notes |
application/Espo/Modules/Crm/Resources/metadata/app/popupNotifications.json | popupNotifications metadata file, contains the url for the back-end controller that retrieves reminders associated with activities and specifies the view which will actually render the notification in the screen. | |
application/Espo/Modules/Crm/Controllers/Activities.php | actionPopupNotifications() | back-end controller, invokes service class to retrieve the notifications. |
application/Espo/Modules/Crm/Services/Activities.php | getPopupNotifications($userId) | gets a list of pending "reminder" records type "Popup" from the database that are liked to the current user. See the structure of the generated list below. |
client/modules/crm/src/views/meeting/popup-notification.js | init() | method inherited from client/src/views/popup-notification.js sets the basic functionality of the popup display and loads the information for one notification |
client/modules/crm/src/views/meeting/popup-notification.js | data() | sends the placeholder data to the template client/modules/crm/res/templates/meeting/popup-notification.tpl to render the notification. |
Data structure of the list of pending popup notifications:
Code:
[ 'id' => value of "id" field in the "reminder" table, 'data' => [ 'id' => value of '"id" field in the table of the entity to which the reminder is linked, 'entityType' => scope of entity to which the reminder is linked (eg: Task), $dateAttribute => name of the field in the linked entity that defines which date attribute is to be used (eg: "dateStart" in "Task"), 'name' => value of the "name" field in the linked entity table ]
I will post more information as I learn more about this subject.
Comment