Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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
share|improve this question
    
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 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 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 at 8:35
    
Thanks Peter for the clarification :) –  Pankaj Gaur Jul 31 at 8:42
    
Refresh worked. F5 ftw! :-) –  Alvin Reyes Aug 10 at 6:06

3 Answers 3

up vote 16 down vote accepted

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();})})();
share|improve this answer
    
Note: some helpful colleagues explained how to make this also work for Tridion 2013 SP1. See the community answer to: tridion.stackexchange.com/q/7418/46. –  Alvin Reyes Aug 6 at 8:50

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!

share|improve this answer

There is more correct way of messages deletion:

$messages.getActiveMessages().forEach(function (message) {
    $messages.executeAction("archive", message.getID());
});
share|improve this answer
    
That's interesting. I had simply found doArchive() in the code and used it. Why is this method "more correct"? –  Dominic Cronin Jul 31 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 at 13:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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