1

I am trying to create a custom VF page that shows records from my standalone custom object in a list along with the picture of the user who created that record..like this (User's image is hardcoded for now).

Sample Screenshot

I have googled and read a lot of posts but its still not clear to me...Can someone please help.

Here is my basic code. How should my Apex function / SOQL query be structured.

Public with sharing class PrintController {


public List<Print__c> getPrints{

    get{
         return [SELECT 
            Comments__c,CreatedById,CreatedDate,Id,IsDeleted,LastModifiedById,LastModifiedDate,LastReferencedDate FROM Footprint__c 
            ORDER BY LastModifiedDate DESC 
            LIMIT 10];
    }
}

I would appreciate any help. I know this is probably a newbie question but looks like my brain just gave up on this :-(

1 Answer 1

2

CreatedBy is a field on every object which is a lookup to the User object. So you can use this field to get the smallPhotoURL in the same query itself, createdBy.smallPhotoUrl. SOmethign like this:

SELECT Comments__c, CreatedById, createdBy.smallPhotoUrl, CreatedDate,Id, IsDeleted, LastModifiedById, LastModifiedDate, LastReferencedDate 
            FROM Footprint__c 
            ORDER BY LastModifiedDate DESC 
            LIMIT 10]
0

You must log in to answer this question.

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