+ Start a Discussion
jcaldjcald 

enter default value with app_user

How do I enter a default value with app_user in this code.

 

                <apex:inputField value="{!Case.Ownerid}"/>

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
jcaldjcald

solved. thank

 

<script type="text/javascript">
document.getElementById('{!$component."id field here"}').value = 'Whatever you want to have as default value';
</script>

All Answers

jcaldjcald

ok. so i managed to find some clues on how to enter a default value into a apex code inputfield. But can't figure out how to get the current user into the field. Here's my code:

 

 

Apex code:

 

<apex:page controller="testControllerExt" showheader="true" sidebar="true" standardstylesheets="true">
 
 <apex:form id="TheForm">
   
  Value:{!TextInput}
   
  <apex:inputtext id="TextInputField" value="{!TextInput}">
  <apex:commandbutton action="{!ProcessForm}" id="theSubmitButton" rerender="TheForm" status="AjaxStatus" value="Submit">
   
 </apex:commandbutton></apex:inputtext></apex:form>
 
</apex:page>

 

 

Apex class:

 

public with sharing class testControllerExt {
 
 public string TextInput {get; set;}
 
 
 public testControllerExt() {
    
  TextInput = '{!$User.FirstName}!';
    
 } // constructor
 
 
 public pagereference ProcessForm () {
  return null;
 }
 
} // main class

jcaldjcald

actually, this still doesn't solve my default value problem. I still need to use:

 

<apex:inputField value="{!Case.Ownerid}"/>

 

and then put in a default value in the field.

jcaldjcald

solved. thank

 

<script type="text/javascript">
document.getElementById('{!$component."id field here"}').value = 'Whatever you want to have as default value';
</script>
This was selected as the best answer