I want to fetch the Contact Id of the Community Portal User. I pass the logged in Member user Id as uId to the custom VF page from the Login page and its rendering fine. But when i try to query for user's contact directly i get an error. Can anyone help?

userId = System.currentPagereference().getParameters().get('uId');
User u = [SELECT u.Id,u.Contact,u.IsActive from User u where u.Id =: userId AND u.IsActive =: true];

What is the best way to do this?

  • The error Msg "Error: Compile Error: No such column 'Contact' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."
    – AjaySFDC
    Commented Sep 8, 2015 at 21:27

1 Answer 1


There is no User.Contact field, instead you have to user User.ContactId

userId = System.currentPagereference().getParameters().get('uId');
User u = [SELECT u.Id,u.ContactId,u.IsActive 
          FROM User u 
          WHERE u.Id =: userId 
            AND u.IsActive =: true];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .