function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anupama@28Anupama@28 

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

Hi,

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.

Anupama


 
SandhyaSandhya (Salesforce Developers) 
Hi,

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
Sandhya
RahulJoshi31RahulJoshi31

 

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
https://www.youtube.com/watch?v=yqn5TTuirdg