+ Start a Discussion

site.com page to get current Community user's contact details


My requierement is to create a site.com page, which displays the current community user's contact details where user can view, edit and save their own contact details.
in community we have option like {!currentUser.Firstname}... but how do i Access the contact information somethind like {!currentUser.Contact.FirstName}, {!currentUser.Contact.Address} etc...

Thanks in advance.


SandhyaSandhya (Salesforce Developers) 

I do not think  {!currentUser.Contact.FirstName} this will work as I know 

{!currentUser.ContactId} will work but not {!currentUser.Contact.Email}

You need to query for this.
public class YourController {
    public Contact userContact { get; set; }

    public YourController() {
        userContact = [
            Select Id, Name /*etc.,*/
            From Contact
            Where Id In (Select ContactId
                         From User
                         Where Id = :UserInfo.getUserId())


Hope this helps you!

If this helps you, please mark it as solved.

Thanks and Regards
Rahul Joshi 75Rahul Joshi 75


Yes, this should be work for community Users.
UserInfo.getUserId() - return id of current logged user.

This query returned the currently logged user

SELECT Id,contactid,contact.FirstName,contact.LastName,contact.email,contact.account.id,contact.account.name FROM User WHERE id =: UserInfo.getUserId()

Make sure your user community Users

How to create Community Users in Salesforce Community Cloud