Pages

Wednesday, May 9, 2012

Where is Chatter Follower information stored?

This article covers the SFDC table which stores Chatter Follower information (ie It stores which user follows which Account, Contact , or any record or User).

The table is

EntitySubscription:

The fields in this table are

ParentId:              The ID of the Account, Contact or any record or User.

SubscriberId:      The ID of the user who follows the record denoted in the Parent ID.


Querying this object would give you Follower Information

For Example:

List<EntitySubscription> myaccsubscribers = [Select ParentId,SubscriberId 
from EntitySubscription where ParentId = '500Q11100046Vt3']; 


To Add followers automatically using Apex, you could insert records into this object. And to Un-follow just delete the relevant records.

EntitySubscription newfollower = new EntitySubscription();
newfollower.ParentId = 'insert id here';
newfollower.SubscriberId = 'insert the user id here';
insert newfollower;

No comments:

Post a Comment