3

I am creating a custom chatter page in Visualforce (kinda reinventing the wheel) by using Connect API. I am able to get the list of feeds for the user using the following connect API call:

feedElementPage = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(null, ConnectApi.FeedType.News, 'me');

When I am trying to display on page I am using Parent property of feedelement to display the user. It works fine when the parent is a user but in case of chatter post in a group, the parent is the group in which the chatter post is made. How can I get the name of the user who created the post in the group to display on page?

I looked into the documentation and could not find the relevant field on feedeleemnt. Also, CreatedBy field is not accessible for feedelement.

<apex:column width="18%">
    <apex:facet name="header">Sender</apex:facet>
    <a href="/{!feedElement.parent.id}">{!feedElement.parent.name} </a> 
</apex:column>

The above code displays User's name in case the post is by a user and group name in case its a group post. I need the name of user who posted in group e.g. Posted by in

Please help!

1 Answer 1

1

It's the actor property of the feed item (docs).

2
  • Hi @alounie, Thanks for reply but we are working with feedelement not feeditem.
    – Shahid Ali
    Commented Mar 6, 2016 at 15:53
  • 1
    FeedElement is an abstract class. FeedItem the only subclass of FeedElement that has an actor property. You'll want to do an instanceof check to see if a FeedElement is a FeedItem, and then cast it to a ConnectApi.FeedItem if it is. The other feed element types (currently Recommendation and Bundle) do not have an actor property because they're system-generated and they don't have a "poster".
    – alouie
    Commented Mar 7, 2016 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .