I would like to be able to clear all the MessageCenter warnings with 1 button or click.

I noticed if I keep my browser window open and the CMS server is unavailable (I go off the VPN) then about every 1 minute I get a new message in the MessageCenter like '/WebUI/Models/TCM54/Services/Workflow.svc/GetListActivityInstances failed to execute. STATUS (0):'

I'm using 2013 SP1 and would like to see if it's possible to:

  • Get a list of the MessageCenter items using the Tridion JS Anguilla API
  • For each item in the list, remove it from the MessageCenter
  • I may not be able to understand it correctly; but isn't it the case that if I clear the browser history...all messages for MessageCenter pop up go away – Pankaj Gaur Jul 30 '14 at 12:36
  • I added an SDL Tridion Idea requesting this feature. Please consider voting for it. You might also notice when closing messages manually the "x" shifts slightly, making it harder to just spam mouse clicks. Maybe related to this is the idea of ignoring certain types of messages (or simply not getting the GetListActivityInstances notice after so many failures). – Alvin Reyes Jul 31 '14 at 0:24
  • 1
    @PankajGaur the cache is unrelated. Just refreshing the page would do the trick, though. But you might not always want to do that, hence the question. – Peter Kjaer Jul 31 '14 at 8:35
  • Refresh worked. F5 ftw! :-) – Alvin Reyes Aug 10 '14 at 6:06
up vote 2 down vote accepted

You got your wish :)

In SDL Web 8, there are now buttons to Mark All as Read and Remove All messages. The latter only appears on the Show All tab.

Screenshot of the aforementioned buttons

My guess is that it's not possible to delete the messages entirely, only to set them to Archived. If you execute the following line of code in your browser console, you should see the messages go from orange to grey.

Tridion.MessageCenter.getMessages().forEach(function(message){message.doArchive();})

Perhaps even handier than the console, is to add it as a "bookmarklet" by creating a browser bookmark with the following code as its target .

javascript:(function() {Tridion.MessageCenter.getMessages().forEach(function(message){message.doArchive();})})();

Following up on top of Dominic's answer, if you want to remove the items from the list you can also call the dispose method.

$messages.getMessages().forEach(function (message) {
    message.doArchive();
    message.dispose();
});

Note that you'll still want to call the doArchive() method first, else you'll end up with no items in the list but the notification number will still show a count for unarchived messages.

If you wanted to only dispose the archived messages, you could do the following:

$messages.getMessages().forEach(function (message) {
    if (!message.isActive()) {
        message.doArchive();
        message.dispose();
    }
});

Also note that even though dispose() removes it from the list in the GUI, the getMessages() method still returns these. Just like the doArchive() method sets the message.properties.inactive property to true, the dispose() method sets the message.properties.disposed property to true. You can check these properties accordingly.

Hope that helps!

There is more correct way of messages deletion:

$messages.getActiveMessages().forEach(function (message) {
    $messages.executeAction("archive", message.getID());
});
  • That's interesting. I had simply found doArchive() in the code and used it. Why is this method "more correct"? – Dominic Cronin Jul 31 '14 at 8:56
  • Looks like under the hood, when you call doArchive, its actually calling executeAction("archive", id). However its also setting the message.properties.timeoutObj to null, so not sure if calling executeAction directly could cause harm by bypassing the nullification of that property – Alex Klock Jul 31 '14 at 13:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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