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

Customer Portal and user info class methods

Hi Friends,


My requirement is to display visual force tab in the customer portal.I have to make this tab visible only when  customer has logged into the portal and then this tab becomes visible.


When the customer logs in .I need to fetch his username ,firstanem,lastname ,email.How do I fetch this information.

I know that before user is created we have to create contact for the user . 

So here is what I have .


contact  c;

user u;

c=[Select contactid from user where id=:userinfo.getUserid()];

u=[select username,firstname ,lastname from contact where id=c.userid];


My concern is ,username is not a field in the contact object.How do I retrieve this username and contact id  and then use both contact id and username in the where clause of the line written above in red.









username field is available in user object, why you are querying contact object. You can fetch contactId as well as username from single query on User object.


user u=[Select contactid,userName from user where id=:userinfo.getUserid()];