[SalesForce] Display Users with Pics and Roles in vf page

I have an requirement where i need to display all the users with their pics and roles as inline HTMl div in vf page.
Can anybody help me out with the aproach.

Regards

Best Answer

You have to write a small Apex method that returns a list of users. And then implement a small pageblock table on the Visualforce page to display that list.

Apex:

public List<User> getUsers(){
    // Here getting ALL users of the org
    // You may have to insert some WHERE clause to limit the list results
    return [Select FirstName, LastName, SmallPhotoUrl From User];
}

Visualforce:

<apex:pageBlock>
    <apex:pageBlockTable value="{!Users}" var="user">
        <apex:column headerValue="Name">
            {!user.FirstName} {!user.LastName}
        </apex:column>
        <apex:column headerValue="Photo">
            <img src="{!user.SmallPhotoUrl}" />
        </apex:column>        
    </apex:pageBlockTable>
</apex:pageBlock>

The result:

enter image description here

Here you can find a complete list with all user object fields

Related Topic