You need to sign in to do that
Don't have an account?

Pre - Populate the field in visual force page
Hi All,
I would like to set the value for the account name field in visual force page when it is opening. I just want to pre-populate the value. I dont find the way to do it. Can anyone help me out ?
Thanks in Advance.
Manoj
Hi,
Here's how you can set the account value for oppty.
public class MyController { public opportunity oppty {get;set;} public MyController(ApexPage.standardController controller) { oppty = (Opportunity)controller.getrecord(); oppty.Account = <VALUE>; } }
All Answers
Based on your logic you can prepopulate the account details in the constructor of the controller for your VF page
Hi sinsiterrulez,
Can you give me any example for this. I just want to set the value for account name field.
Thanks
Manoj
Hi,
You can set the account name in the controller and using merge field populate field in page.
For example: let your controller like this...
public class MyController
{
public MyController(ApexPage.standardController controller)
{
name=' any name' ;
}
public String name{get; set;}
}
/*****************Page*******************/
<apex:page standardController="Account" extensions="MyController">
<apex:outputLabel>Name</apex:outputLabel>
<apex:outputField value="{!name}"/>
Thanks,
</apex:page>
If that's what you were looking for, you'll find the cookbook very helpful. It contains code samples for most introductory VF needs.
If that's not what you were looking for, maybe a use case would clarify?
I don't think creating a controller for this is good advice here, since the standard controller provides the functionality to do this without a controller class. Controller classes require test coverage and increase development time / requirements.
Hi,
Here's how you can set the account value for oppty.
public class MyController { public opportunity oppty {get;set;} public MyController(ApexPage.standardController controller) { oppty = (Opportunity)controller.getrecord(); oppty.Account = <VALUE>; } }