- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
11-30-2012 05:49 PM
It's great that we can get profile urls using the fields on the User object. The problem is they don't seem to be assible from a feed query. So if I have a custom object Custom__c and I turn chatter on for it then try and get the feed with a query to Custom__Feed in apex. I can't access the profile images for the posts with CreatedBy.smallPhotoUrl because I get the following error:
No such column 'smallPhotoUrl' on entity 'Name'
So my question is, is there anyway to get the photo urls for the feed items in a single query or are we destined to do multiple queries and create wrapper classes to include the small photo urls :( I would really like to avoid this.
12-02-2012 10:51 PM - edited 12-02-2012 10:52 PM
Yeah, you can't get smallPhotoUrl directly from Chatter object, but add only one SOQL will be fine, if you don't have too many users in the org. Like this,
AccountFeed af = [select id, createdbyid from AccountFeed limit 1];
Map<Id, User> usermap = new Map<Id, User>([select Id, smallPhotoUrl from user]);
System.debug(' --------- ' + usermap.get(af.createdbyid).smallPhotoUrl ) ;
If you got the createdbyid of the post, then you can get this user's photo link from the Map.
12-02-2012 11:11 PM
SmallPhotoUrl gives the User Thumbnail Profile photo, which is available only in API version 20.0 and in later versions.
If you are using the query in AJAX, make sure you use API Version above 20 as below,
If you are using the query in VF page, make sure the VF page version is above 20.
You can refer this LINK
Salesforce For All
Mrk this post as solved, if it helps you