+ Start a Discussion
MrHammyMrHammy 

How do I use getFeedElementsFromFeed

I am trying to replace a chatter feed I use in a VF page, in the past I used 
 
return ConnectApi.ChatterFeeds.getFeedItemsFromFeed(communityId, ConnectApi.FeedType.Record, groupId).items

But that has gone away in api 31 (it also just broke on its own somehow) and I want to use the most up-to-date way of getting the data. I am getting  the error   Line: 6, Column: 90 unexpected token: ','  when I try and run this in execute anonymous,
 
private static List<Community> customCommunity = [Select NetworkId, Name From Community where name = 'Sales Community'];
    private static String communityId = customCommunity[0].NetworkId;
    private static List<CollaborationGroup> CollaborationGroup = [SELECT Id FROM CollaborationGroup where name = 'Agency Forum'];
  	private static String groupId = CollaborationGroup[0].Id;

	public static ConnectApi.FeedElementPage ConnectApi.getFeedElementsFromFeed( communityId , ConnectApi.FeedType.Record , groupId);

I can find no real world examples of how to do this
NagaNaga (Salesforce Developers) 
Hi MrHammy,

In API versions 30.0 and earlier, a Chatter feed was a container of feed items. In API version 31.0, the definition of a feed expanded to include new objects that didn’t entirely fit the feed item model. The Chatter feed became a container of  feed elements. The abstract class ConnectApi.FeedElement was introduced as a parent class to the existing  ConnectApi.FeedItem class. The subset of properties that feed elements share was moved into the ConnectApi.FeedElement class. Because feeds and feed elements are the core of  Chatter, understanding them is crucial to developing applications with Chatter in Apex. For detailed information, see Working with Feeds and Feed Elements.

Please follow the below link for more info

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm

Best Regards
Naga Kiran
alouie_sfdcalouie_sfdc
On line 6, the ChatterFeeds class name is missing. ConnectApi.getFeedElementsFromFeed should be ConnectApi.ChatterFeeds.getFeedElementsFromFeed.
jody_blyjody_bly
https://www.salesforce.com/us/developer/docs/apexcode/Content/connectapi_examples_get_feed_elements.htm (https://www.salesforce.com/us/developer/docs/apexcode/Content/connectapi_examples_get_feed_elements.htm" target="_blank)