How to mass delete Tridion MessageCenter warnings?

16

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

robrtc

Posted 2014-07-30T11:56:39.613

Reputation: 6 861

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 – 2014-07-30T12:36:50.277

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 – 2014-07-31T00:24:49.480

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 – 2014-07-31T08:35:17.410

Refresh worked. F5 ftw! :-) – Alvin Reyes – 2014-08-10T06:06:32.047

Answers

2

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

Peter Kjaer

Posted 2014-07-30T11:56:39.613

Reputation: 19 149

18

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();})})();

Dominic Cronin

Posted 2014-07-30T11:56:39.613

Reputation: 14 997

Note: some helpful colleagues explained how to make this also work for Tridion 2013 SP1. See the community answer to: http://tridion.stackexchange.com/q/7418/46.

– Alvin Reyes – 2014-08-06T08:50:51.723

14

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!

Alex Klock

Posted 2014-07-30T11:56:39.613

Reputation: 2 901

3

There is more correct way of messages deletion:

$messages.getActiveMessages().forEach(function (message) {
    $messages.executeAction("archive", message.getID());
});

Boris Ponomarenko

Posted 2014-07-30T11:56:39.613

Reputation: 466

That's interesting. I had simply found doArchive() in the code and used it. Why is this method "more correct"? – Dominic Cronin – 2014-07-31T08:56:12.793

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 – 2014-07-31T13:49:09.597