I am wondering which object holds the details of "follow". When i click the follow link in Account detail page I understand we can follow the record changes. Based on that understanding i have searched the salesforce schema for the object which might have stored the "follow" details but i did not find a one. Where could i find the details of the follow of a record and which object holds that detail? Please suggest.
2 Answers
The object that you are looking for is called EntitySubscription.
From the documentation
Represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user.
You can see the full documentation using the link below.
https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_entitysubscription.htm
You could also check out the Chatter cheat sheet as it is covered in that as well
http://media.developerforce.com/cheatsheets/SF_chatter_4Pg_HR.pdf
You can also get that information via the ConnectAPI - details here
This method returns a 'followerpage' that lets you get at the followers for a specific page:
ConnectApi.FollowerPage accountfollowers = ConnectAPI.Chatter.getFollowers(String communityId, String recordId)
e.g. :
ConnectApi.FollowerPage accountfollowers = ConnectAPI.Chatter.getFollowers(null, '001R000000pesmV'); for (ConnectAPI.Subscription s: accountfollowers.followers ) { system.debug(s.Subscriber); //details about follower system.debug(s.Subscriber.Id); //User Id system.debug(s.Subscriber.Name); //User Id }