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
Siva SakthiSiva Sakthi 

how to display the current user name in textbox ?

how to display the current user  name in  textbox using controller  ? (Sample Code)

Best Answer chosen by Admin (Salesforce Developers) 
souvik9086souvik9086

User usr = [SELECT ID, Name FROM User WHERE ID = :UserInfo.getUserId()];

 

You will get the name in {!usr.Name} in page.

 

You can also get the user name directly in vf page

 

{!$User.FirstName} {!$User.LastName}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

All Answers

sambasamba

 

Hi Maheshwar,

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

 

 

Please let me know if you have any questions.

 

 

Thanks,

Samba

souvik9086souvik9086

User usr = [SELECT ID, Name FROM User WHERE ID = :UserInfo.getUserId()];

 

You will get the name in {!usr.Name} in page.

 

You can also get the user name directly in vf page

 

{!$User.FirstName} {!$User.LastName}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

This was selected as the best answer
Siva SakthiSiva Sakthi

Thanks. I got it