I'm running into a bit of an issue. I'm trying to have two fields auto-populate on the VisualForce page load to save the reps from having to fill them out. (They are required name fields but we have a system that dictates the names of Opportunities and quotes.) I have tried using Jquery but I don't know enough about Java to know if I'm editing correctly. I've also tried controller solutions but the code is a bit foreign to me and hard to dictate. Are there any other solutions I'm missing?

  • Are you trying to auto populate two fields on the VF page when the page loads? Is there a controller tied to your page? Can you please help us understand your scenario in a easy way? Jul 14, 2014 at 13:09

1 Answer 1


If the page is creating new objects, then the simple way to have the fields in the Visualforce pre-popupated is for the controller to default the values e.g.:

public with sharing class MyController {
    public MyObject__c myObject {
        get {
            if (myObject == null) {
                myObject = new MyObject__c(Name = 'Default Name');
            return myObject;
        private set;

and then when the page displays the field it will already have a default value:

<apex:inputField value="{!myObject.Name}"/>

While this could also be done using JavaScript, as you have noticed that requires additional knowledge and can be tricky to get right at first.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .