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
ArjunmcaArjunmca 

How to bind User Name to Input field

 How to bind user name to an Input field. I knew that we can get user name by passing user id to visual force page as explained in the below link

 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_controller_quickstart.htm

 

But i am not able to find user id from the page. We have only one visualforce page which was deployed in the production.

When user acccess that page by entering url in IE, it asks for user name and password to login, after entering login details, VF page displays, but it doesn't have user id in the url. Then how can i get user name to display a message as "Welcome <UserName>".

 

     <apex:inputField value="{!User.FirstName}" />

 The above binding is not working.  Please let me know how to resolve this issue.

 

 

Rehan DawtRehan Dawt

Hi Arjun,

 

I think you are missing with standardController="User" in <apex:page> tag.

 

Please check this code

<apex:page standardController="User">
	<apex:form>
		<apex:pageBlock>
			<apex:inputField label="First Name" value="{!User.FirstName}" />
		</apex:pageBlock>
	</apex:form>
</apex:page>

 

After saving this page, just provide any user id in url.

Eg. /apex/page1?id=005989898988

 

 

 

ArjunmcaArjunmca

There are no multiple pages to pass id from one page to another page. There is only one Visual force page and its already in already in production, its not showing id of the user at the end of url.

 

I tried with {!$User.Firstname}. But i got below below error.

 

Error: Could not resolve the entity from <apex:inputField> value binding '{!$User.Firstname}'. <apex:inputField> can only be used with SObject fields.