[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.


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.


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];


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

The result:

enter image description here

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

Related Topic