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
kannapapikannapapi 

How to get photoURL from FeedItem object?

Hi All,
How to get photoURL from FeedItem object?
i have tried Createdby.smallphotourl but it's not working for FeedItem object...
Best Answer chosen by kannapapi
Swati GSwati G
You will need to query createdById from FeedItems and then perform another queryon user object to get smallphotourl. As CreatedById is of polymorphic type you cannot get smallphotourl directly in query or you can enable typeof query and get small photo url in same query.
TypeOf query example: http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_typeof.htm

You can use connectapi as well to get feeditem information and you will get all information in this.

Connect Api: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_getFeedElement_1

All Answers

Swati GSwati G
FeedItem does not have any photo. It displays its related parent photo.
kannapapikannapapi
Hi Swati,
Thanks for reply.
i need photo of the feeditem owner. How to get this?
Swati GSwati G
You will need to query createdById from FeedItems and then perform another queryon user object to get smallphotourl. As CreatedById is of polymorphic type you cannot get smallphotourl directly in query or you can enable typeof query and get small photo url in same query.
TypeOf query example: http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_typeof.htm

You can use connectapi as well to get feeditem information and you will get all information in this.

Connect Api: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_getFeedElement_1
This was selected as the best answer
kannapapikannapapi
Hi Swati,
        Through wrpper class which has both feed item and user object queries the issue has been solved.
Thanks for the reply..