Notification BeforeCreate event not firing


I am building a solution that needs to do something whenever a notification is sent in the community and thought the best way to handle this would be on the notification before create event handler.  As such I have created a very simple plugin as follows;

namespace NotifcationEventHandler
    public class NotificationHandler : IPlugin
        public string Name => "Event Handler Test";

        public string Description => "Tests and handles event notifications";

        public void Initialize()
            Apis.Get<INotifications>().Events.BeforeCreate += new NotificationBeforeCreateEventHandler(Notification_Before_Create);

        private void Notification_Before_Create(NotificationBeforeCreateEventArgs e)
            //Here we will send a notication

            string s = e.ContentUrl;

Clearly the event doesn't actually do anything (for simplicity), but if I place a breakpoint within the handler I get different results, for example,

  1. Sending a private message between two users when I have two different browsers open and both users logged in - the breakpoint is hit
  2. If one of the browsers is closed and the user in the first browser sends a message, the breakpoint is not hit - I did consider that this could be because the responsibility would then fall to the job service, however, the plugin is also installed there and debugging that confirms that the breakpoint is not hit

Is anyone able to advise what I could be doing wrong here?  Ultimately I am looking to capture whenever any notification is sent.

We are testing with, but have the same problem with previous versions of 12.

Any help is, as always, greatly appreciated.



Added version information.
[edited by: James Phillips at 9:26 AM (GMT 0) on Fri, Oct 22 2021]
  • Hi James,

    Are you wanting to capture all instances of every notification created - for instance, sending notification to all subscribers about a new blog post - or just for private messages? 

    For private messages (aka conversations), check the Conversation Messages In-Process API Service for those events.

    For notifications, you will want to hande the BeforeUpdate event as well. Notifications are dynamic and can be updated based on similar events occuring (for instance, "UserA commented on this blog post" to "UserA and UserB commented on this blog post"). Likely in your instance, you are seeing a case of the conversation message notification being updated, because a previous message was sent recently.

  • Hi Steven,

    Thanks for the reply and yes, we are looking to capture all instances of every notification.

    Are you therefore saying that this is intended behaviour and that if we handle BeforeUpdate this will give us what we need?



  • Yes, this is intended, and yes the BeforeUpdate will trigger on instances where there is an existing notification for the action taken that is being updated instead of a new one created.

    I'll also just note to consider usage of After events vs Before, unless you are aiming to update the entity itself, compare before/after states, or some other action that necessitates use of the Before events.

  • That's great - thanks.  I will review and test and report back here - appreciate the information.