Announcement

Collapse
No announcement yet.

How are popup notifications generated in Espo

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How are popup notifications generated in Espo

    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:
    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
    ]
    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.
    Last edited by telecastg; 10-11-2020, 03:10 AM.

  • #2
    Thx for sharing.

    Comment


    • #3
      i love when you do these posts! it's great documentation especially since string-dependency injection makes static analysis difficult
      Last edited by tothewine; 11-26-2020, 06:34 PM.

      Comment


      • #4
        Hi, could you please describe an example of how you can trigger a modal notification in code along the lines of how it is done for an incoming call? I want to implement such notifications

        Comment


        • #5
          It's bit different in new versions and easier for developers. https://docs.espocrm.com/development...notifications/

          Comment


          • #6
            Originally posted by yuri View Post
            It's bit different in new versions and easier for developers. https://docs.espocrm.com/development...notifications/
            One example of the code would be very helpful. Lets say that in workflow I want to delete a newly created record and then display a popup notification to the user that it was not ok to create a record for some reason.

            Comment

            Working...
            X