Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the expression to access User's Contact record fields in Visualforce? I need in for Customer Portal.

share|improve this question
up vote 2 down vote accepted

You can get the Contact record in your controller by using the UserInfo object and something along the lines of the following query. Then you can reference it in your Visualforce page.

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())

share|improve this answer

After quick look I believe {!$User.Contact.Email} etc should be ok.

share|improve this answer
{!$User.ContactId} is working but {!$User.Contact.Email} is not working. Do you know any workarounds? – Suman Krishna Saha Jan 18 '13 at 8:18
Uh, that's a bad news. Try making a formula on User that'd reference the Contact's field? I suspect it won't work either though... Looks like you'll need an apex controller then or maybe some workflow/trigger that'd copy data over when source (Contact) changes. – eyescream Jan 18 '13 at 8:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.