+ Start a Discussion
Mano sfdcMano sfdc 

{!$User.Name} It shows error

Hi Experts,

In VF Pages code, {!$User.Name} It gives error.
Anyone please help me, how to fetch User object name field value into VF Page code.
Thanks in advance.
PratikPratik (Salesforce Developers) 
Hi Manohar,

Use this:  {!$User.firstname}  {!$User.lastname}

Thanks,
Pratik

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
Mano sfdcMano sfdc
Hi Pratik,

Thanks for quick reply.
But i don't want First Name and Last Name.
Because we have a field name as "NAME" in User Object.
Why we go for other?
PratikPratik (Salesforce Developers) 
Hi Manohar,

For any custom field:

Use:  {!$User.customfield__c}

Thanks,
Pratik
Mano sfdcMano sfdc
Hi Pratik,

you are new to salesforce?

Standard Object: User
Standard Field: Name

Please see below Image.

.User-added image

Thanks,
Manohar
Mano sfdcMano sfdc
Hi Experts,

I know to resolve my issue with below options, but i want to get it done with visualforce page.
 
1. Use {!$User.FirstName} {!$User.lastName}
2. Create a custom formula field on the user (FirstName + ' ' + LastName)
3. Use a controller or extension to get; set; a variable using UserInfo.getName();
 
Please anyone sort-out this.
 
Thanks,
Manohar.
Roy LuoRoy Luo
I am not sure why $User,Name doesn't work, but would you consider the following 'get it done with visualforce page'?
 
<apex:page >
  <h1>Hello {!$User.FirstName}&nbsp; {!$User.LastName}</h1>
  This is your new Page
</apex:page>