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
anvesh@force.comanvesh@force.com 

how to display the current user name in textbox ?

i  have a feild  named  owner  of type textbox and have lookup relation....

 

now the thing is   when i  clicked  new  button (to create)  all fields are displayed including owner field but this feild default should displayed  as  current user name in the text box...how we can do this  any one pls?.

vbsvbs

Anvesh - If you are using an inputField component on your VF page you can instantiate the object in the constructor as 

Object__c obj = new Object__c(Owner = UserInfo.Id) or obj.Owner = UserInfo.Id. This should default the owner to current user and show the users name in the page.

anvesh@force.comanvesh@force.com

yes but i am creating for case  object that means standard obj....how we ll get VF page for case object

vbsvbs
Anvesh - If this is a standard page then this is the default functionality on the Case New/Edit page. You do see the current user as the Case Owner and this is read-only. What do you need changed here? Your requirement is not quite clear.
anvesh@force.comanvesh@force.com

let me clear  you my task  first.....

 

for case  object  there is a requirement  to create  a  feild  'Owner' (this is custom feild) (Other Than  Case Owner) , and  that  Owner  field  has a look up and when we click that look up  all  sfdc users should need to  be display. by default in that  owner feild  textbox  current user name  should need to be displayed.

vbsvbs
Default values for a lookup are not supported standard behaviour. The alternative would be a VF page or passing parameters through URL that default the values.
Priya ChimalgiPriya Chimalgi
Hello Anvesh,

@Anvesh I have the same issue, I was searching and got it here, I know it is very old post but wanted to know how did you solve this issue,As I am new to salesforce administrator 
You can reach me at priya@ezanchorpuller.com 
Any help will be appreciated