Thursday, August 22, 2013

Display Chatter in Visualforce pages

               Display Chatter Widget in VisualForce Pages

Chatter is a very useful widget available to collaborate with other users or a group of users in your Salesforce Org. It is visible (at the bottom corner of the window on right hand side) in all standard Salesforce views. But it will not be visible on custom developed VisualForce pages by default. 

To enable it on VisualForce Pages you need to follow 2 steps.

1) change the default settings. 
    Go to Your Name-->Setup-->Customize-->Chatter-->Chat Settings
       You can see there two options
          1. Chat Settings.
          2. Visualforce Settings.
       Click on Edit & Check the box next to "Allow" under VisualForce Settings.  Click on Save.

2) Set Correct attributes to Visualforce Page <apex:page> tag. 

       You need to add "Showheader=ture" attrubute on the <apex:page> tag.
       If you don't want to show header but chatter widget must be shown, then you have to use two attributes.
           showheader=false
           showchat=true


Example 1:

  <apex:page standardController="Account" showHeader="true">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Output of this page with chatter widget displaying @ the bottom right hand side corner of the window



Example 2:

<apex:page standardController="Account" showHeader="false" showChat="true">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Output of this page with chatter widget displaying @ the bottom right hand side corner of the window



To prevent the chat widget from displaying on a specific Visualforce page, do any of the following:
  • Turn off the Salesforce tab header on your page by setting <apex:page showHeader=”false”>.
  • Set the page contentType to something other than text/html, for example, <apex:page contentType="text/plain">.


7 comments:

  1. Can I create dynamic objects? Means Need to create an object with fields in run time.Is that possible?
    Regards,
    Salesforce training in Chennnai

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. i want to change the font size and font types of things i write in chatter.. is it possible?

    ReplyDelete
    Replies
    1. That's good question, I thought about this too lately, and also is it possible to show\hide the button that hides\shows chatter feed in visualforce page?

      Delete