How to "Hide Chatter" by default everytime a user visits a page

4:23 PM


UPDATE: With the Spring 2013 release, the steps described below have become bit more complicated.

The Show/Hide Chatter toggle sometimes might make the page look too long. When you have a lot of chatter going on, the page becomes really big and your detail page or the home page goes way down under.

Even when you can't control the size of your chatter frame, hiding it by default would be ideal i think. And so, this bit of code. Add this code to a home page component, to a visualforce page, or add it to a visualforce page and embed it within standard page layouts.

Use this, when you have chatter inside a visualforce page. Make sure that this code gets called after the entire page has loaded. Pasting this code towards the end of the visualforce page should be fine. In case it doesn't work, put the code inside a function and call the function after page load using "window.onload = functionname();"

var e = document.getElementById("showFeedLink");
     if(e.style.display == "none") 
           chatter.getFeed().toggle('{"subjectId":"a4MV00000032ixk","feedType":"ENTITY"}', false);
The portion marked in RED denotes the record ID.

Use this, when you want to hide chatter in the home page. Create a new Home Page Component and select "HTML Area" and then check the "Show HTML" checkbox and paste this code.
function hidechatter()
{
     var e = document.getElementById("showFeedLink");
     if(e.style.display == "none") 
           chatter.getFeed().toggle('{"subjectId":"a4MV00000032ixk","feedType":"NEWS"}', false);
}
window.setTimeout("hidechatter()", 2000);  
} 

The portion marked in RED denotes the USER ID.

8 comments

  1. Thanks so much for this muah!

    ReplyDelete
  2. This is not working post spring 2013.
    Please suggest workaround

    ReplyDelete
    Replies
    1. Does not work.
      "numFeedItems":20 seems like a dynamic value.

      Delete
    2. Did you try setting random values for numFeedItems? have an alert statement after chatter.getFeed().toggle() function to know whether the function is getting called in the first place?

      Also, in which page are you trying to suppress chatter? Home Page or a record?

      Delete
    3. Thanks Edwin Vijay....This is working Now....You are awesome

      Delete
  3. Only works with the correct / current userId and the numFeedItems.
    With no visible way of fetching these values on the fly, there seems to be no viable solution / workaround at this time.

    ReplyDelete
    Replies
    1. try with the above code, you will have to pass the ID though at runtime

      Delete