Wednesday 1 February 2012

Embedding Chatter in Visualforce Pages


As we know that, Chatter in salesforce makes our applications more collaborative. Chatter can be enabled for both standard and custom objects, making us to know about the changes like new contact created, stage field changes etc., in real-time.

Navigate to the following path to enable Chatter,
Your Name ➤ Setup ➤ Customize ➤ Chatter ➤ Settings

If Chatter is enabled for an organization, it will appear in Users profile page and in Objects Home Page. Embedding Chatter in Visualforce Pages can be made possible by using the <chatter:feed> tag, introduced as a part of Winter '11 Release.



This tag takes the required attribute entityId, which may take values like user Id, record Id from URL etc., as shown below

<apex:page standardController="Opportunity" recordSetVar="Oppties">
<apex:sectionHeader title="List" subtitle="Opportunity"/>
<chatter:feedWithFollowers entityId="{!$User.Id}"/>
<apex:pageMessages />
    <apex:pageBlock >
        <apex:pageBlockTable value="{!Oppties}" var="oppty">
            <apex:column headerValue="Name" value="{!oppty.Name}"/>
            <apex:column headerValue="Stage" value="{!oppty.StageName}"/>
            <apex:column headerValue="Close Date" value="{!oppty.closedate}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

The tag <chatter:feed/> displays Chatter without their followers.

Note: Chatter components are unavailable for Visualforce pages on Force.com sites

2 comments:

  1. yes its valuable.....

    ReplyDelete
  2. Hi Bharat Mohan ,

    Do u know how to replicate the same for external authenticated users in visualforce pages !?

    ReplyDelete