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
Sure@DreamSure@Dream 

CreatedBy Id for FeedItem

Hi all,

How to get the createduser's id for a feedItem using ConnectApi?
Using getfeedItemsFromFeed(), I am getting feed from a chatterGroup.

Thanks,
Best Answer chosen by Sure@Dream
Sure@DreamSure@Dream
Hi,

I am able to get the feeditem's created user id as follows:

ConnectApi.ActorWithId actorWithId=(ConnectApi.ActorWithId)feedItem.Actor;

String userId=actorWithId.Id;

Thanks.

All Answers

Swati GSwati G
Hi,

There are mutiple methods available to get feedItem based on feedtype.

ChatterFeeds Methods listed here: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm

You can use getFeedItemsFromFeed(String, ConnectApi.FeedType, String) which returns the first page of feed items for the specified feed type, for the specified user. The page contains the default number of items.

getfeedItemsFromFeed() will return  ConnectApi.FeedItem​Page which contains items which of type ConnectApi.FeedItem.

ConnectApi.FeedItem: http://www.salesforce.com/us/developer/docs/dbcom_apex290/Content/connectAPI_outputs.htm#capi_Feed_Item_output 

ConnectApi.FeedItem has actor which is the entity that created the feed item.
Sure@DreamSure@Dream
Hi,

I am able to get the feeditem's created user id as follows:

ConnectApi.ActorWithId actorWithId=(ConnectApi.ActorWithId)feedItem.Actor;

String userId=actorWithId.Id;

Thanks.
This was selected as the best answer