How are popup notifications generated in Espo

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • telecastg
    Active Community Member
    • Jun 2018
    • 907

    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.
  • huscmk
    Junior Member
    • Feb 2017
    • 17

    #2
    Thx for sharing.

    Comment

    • tothewine
      Active Community Member
      • Jan 2018
      • 373

      #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

      • m.poliit
        Junior Member
        • Jun 2023
        • 11

        #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

        • yuri
          Member
          • Mar 2014
          • 8440

          #5
          It's bit different in new versions and easier for developers. https://docs.espocrm.com/development...notifications/
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • rouhu
            Member
            • Sep 2020
            • 39

            #6
            Originally posted by yuri
            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...