I am using the notification framework for publishing the notification messages when an event is executed. I am seeing a weird behavior that my notifications get duplicated.
After each occurrence of the event, I get more messages than previously.

enter image description here

I can see in the logs, that this message is only sent once and the event is also only executed once.

Also, when I reset the cache and reload the browser, the number of occurrences 'resets' - but again, with each execution it goes up.

Here is my NotificationHandler.js code:

var notificationHandler = function (event) {
    if (event.data.action !== "client:CreateFolderEventsNotification") {
    var userSettings = Tridion.ContentManager.UserSettings.getInstance();
    if (event.data.details.creatorId === userSettings.getUserId() || event.data.details.creatorId === "-1") {

        if (Tridion.MessageCenter.getInstance()) {
            var title = event.data.details.title;
            var description = event.data.details.message;

            if (event.data.details.messageType === "Goal") {
                Tridion.MessageCenter.registerGoal(title, description, true);
            } else if (event.data.details.messageType === "Warning") {
                Tridion.MessageCenter.registerWarning(title, description, true);
            } else if (event.data.details.messageType === "Error") {
                Tridion.MessageCenter.registerError(title, description, true);
            } else if (event.data.details.messageType === "Notification") {
                Tridion.MessageCenter.registerNotification(title, description, true);
            } else {
                console.log("Unrecognized message type: " + event.data.details.messageType);
var notificationBroadcaster = Tridion.Web.UI.Core.NotificationBroadcaster.getInstance();
notificationBroadcaster.addEventListener("notification", notificationHandler);

Any idea what am I doing wrong?

  • Could it be that `notifiationBroadcaster.addEventListener("notification", notificationHandler)' is called for each message/event? – Albert Romkes Jul 30 at 20:12
  • that's what I think as well, but this is pretty much a code from the sample github.com/sdl/publish-transaction-notification/blob/master/… – Bartosz Jul 30 at 20:18
  • The more reason to verify it ;) – Albert Romkes Jul 30 at 20:21
  • Seems likely that the JavaScript code that adds the event listener is being run multiple times. How/where is the script included? – Peter Kjaer Aug 8 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.