6

I am sending a variety of notifications via

SP.UI.Notify.addNotification("blah", true);

setting the "sticky bit" to true so that the notification stays visible. When I display a second notification, I want to remove the current notification, but I need the id of the notification to remove it with

SP.UI.Notify.removeNotification(id)

Is there any way to remove all of the current notifications or to get the ids of the the current notifications?

4

I had the same requirement as you on my last project and used the same approach that you did:

[Edit- moved from within question]

var currentNotificationID = "";

function replaceNotification(message) {

    if(currentNotificationID != "") {
        SP.UI.Notify.removeNotification(currentNotificationID);
    }

    currentNotificationID = SP.UI.Notify.addNotification(message, true);

    return;
}

function showError() {

    replaceNotification('Error message...');

    return;
}

[End Edit]

The API doesn't offer the method you're looking for on the SP.UI.Notify class.

It does however offer this method on the SP.UI.Status class:

SP.UI.Status.removeAllStatus(true);

Would this be an acceptable alternative? Click Here for more MSDN documentation on the SP.UI.Status class.

  • I was asked to use Notify over Status, but the above worked well enough for what I needed. I added this solution to your answer and will mark accepted once my edit gets peer reviewed. Feel free to change it. – xdhmoore Nov 23 '11 at 18:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.