To get the list of users that you are following, use the following Visualforce code:
<apex:outputPanel id="resultPanel"> <b>Following ({!followings.size})</b> <apex:dataList value="{!followings}" var="f"> <apex:outputText value="{!f.parent.name}"> </apex:outputText> </apex:dataList> </apex:outputPanel>
The following is the code for the custom controller:
public List <EntitySubscription> getfollowings() { EntitySubscription[] followingES = [select id, parentid, subscriberid, parent.name,subscriber.name from EntitySubscription where subscriberid =:uid]; List <EntitySubscription> following = new List <EntitySubscription> (); String userSObjectPrefix = User.sObjectType.getDescribe().getKeyPrefix(); for( EntitySubscription es: followingES ) { if( ('' + es.parentid).substring(0,3) == userSObjectPrefix) following.add(es); } } return following; }
The EntitySubscription
object stores information about entities such as users or records that you are following or subscribed to. In the custom controller code, we are firing a query over the EntitySubscription
object to get the list of users and displaying the result by using the output panel and output text. Following are two attributes of the EntitySubscription
object that we used in the preceding code:
Parented
: People (subscriberid
) subscribed to my feedsSubscriberid
: Subscribed to other peoples (parentid
) feedsIn this change, when you choose the user from the dropdown, it will show the list accordingly.
3.128.197.221