function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karthick RajaKarthick Raja 

Follow another user in Visualforce page

Hi folks,
        Can anyone tell me how to follow the another user in Salesforce Org?
There are 3 user in my org.
like user1,user2,user2

User3 wanna follow user1 
for that how to write vfp;

My VFP:
 
<apex:page standardStylesheets="true" showHeader="false">  
   <chatter:feedwithFollowers entityId="{!$User.Id}"/>
   
   

   <chatter:follow entityId=""  />//I dono what to write here
   
</apex:page>

Thanks in advance
Karthick
ShaminaShamina
Hello,

You have to indicate the User Id in the attribute entityId
<chatter:follow entityId="UserId"  />

Refer to these chatter code recipes here: https://developer.salesforce.com/page/Chatter_Code_Recipes

You can also add an apex controller to query the list of User Ids you need, see sample code below:
 
<apex:page controller="VFC06_ChatterFollow" standardStylesheets="true" showHeader="false">  
   <chatter:feedwithFollowers entityId="{!$User.Id}"/>
   
   <apex:repeat value="{!userList}" var="usr"> 
       <apex:outputText value="{!usr.LastName}" /> <chatter:follow entityId="{!usr.Id}"/>
       <br/>
       
   </apex:repeat>
   
</apex:page>
 
public class VFC06_ChatterFollow{

    public list<User> userList {get;set;}
    
    public VFC06_ChatterFollow(){
        userList = [select id, lastname, firstname, profile.Name, profile.Usertype from user
                        where isactive = true
                        and profile.Usertype = 'Standard'
                        and id != :UserInfo.getUserId()];
        
    }
    
}

Best Regards,
Shamina
Karthick RajaKarthick Raja
@Shamina,
          Thanks for your response.
But it doesnt show the feeds that are posted by another After clicking the follow button on the bottom side ..
For Example
there are two users
if user2 create a feed then user1 can see that record
For that I have create a Visualforce page that you given above.
I didnt see the feeds of user2 when I am running visualforce page on user1 login


Please help!
Karthick RajaKarthick Raja
 Hy Shamina,
         Please help!
ShaminaShamina
Hello Karthick,

The previous code provided was only to follow a specific user from a visualforce page.

If you want to show the chatter feeds for a user, check the samples codes provided for recipe 8 and 9 on this page:

https://developer.salesforce.com/page/Chatter_Code_Recipes

 
Karthick RajaKarthick Raja
@Shamina
Thanks for yur respone.
I have seen link that you mentioned.
I dono how to implement that in visualforce with same UI.
(I need a code)

Please help!
Karthick RajaKarthick Raja
Hy shamine,
     Are you there?
ShaminaShamina
Karthik,

Use the chatter:feedwithFollowers tag to show the feeds of another user, where entityid = id of user2
But you can have only one chatter:feedwithFollowers tag in your visualforce page.
Example below where "usr" is a variable in your apex controller of the user2, and the page will be viewed as user1
<chatter:feedwithFollowers entityId="{!usr.Id}"/>