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

Populating input fields based on value in lookup field

I'm making a visualforce page that is a form for submitting cases. What I want to do, is use the Account lookup input field to populate other input fields on the form with information from the account that is being looked up.


Is this possible to do using the standard case controller? Even if the case hasn't been created yet? Can someone give me some guidance. 


Thanks in advance. 




I'm in the process of doing something similiar. I do not think you can do this in a standard controller and will need a custom controller - or at least an extension.


Since there's Account ID isn't available when the page first loads - the standard controller doesn't know it needs to query for that Account and pull back data.


For that reason, I'm thinking you'll need an extension. Especially if the case isn't created yet. You should have get and set methods for each of your input fields. You should also have a method for querying data from the Account using a get method for your Account input field as a variable.


Then in your page, you'll want to add an apex function that calls a page reference that'll update all your get/set methods. I'm not sure which event you'll want to use with that - maybe onclick?




Hi Brian,


      I have one similar requirement. But I am unable to get the value which I selected in input field.



My code is :


public void setInv(string value)
    Inv = value;


here inv is a value for input field. I am not able to get the value in Inv which I selected in input field.



Is this way of writing set method is right or not? Please help me.





Appshark Software Pvt. Ltd


I've not used the set method in the same manner as you. Here's an example of one that I did. I had a custom field on the Opportunity that I wanted to pre-populate when someone went to my edit page. This can also be done with an InputText or InputTextArea.


//Set a private string for the controller private String SummaryTerms; /Define the get method public String getSummaryTerms() { Opportunity ThisOpp = (Opportunity)controller.getrecord(); //If the value is null, populate if(ThisOpp.Summary_Terms__c==null) { ThisOpp.Summary_Terms__c = '1.) Payment must by made in US dollars.' + '\n\n' +'2.) The Annual Agreement covers 20 months of Pharmacy OneSource service fees from the subscription term.'; } //Return the value - this return either the previous value or the string above return ThisOpp.Summary_Terms__c; } //This sets the SummaryTerms public void setSummaryTerms(String SummaryTerms) { this.SummaryTerms = ThisOpp.Summary_Terms__c; }