You need to sign in to do that
Don't have an account?
Narayan H
Auto-Populate Company Info based on Account Number
I want to auto-populate Account Name and Address fields from matching Account record on entering Account Number. On entering Account Number it should do a auto look-up and if found any matching record then the Account and Address fields to be populated. Here is my VF page. Appreciate your help
<apex:page standardController="RMA__c" >
<apex:form >
<apex:pageBlock >
<apex:outputLink value="/{!RMA__c.Id}" >Go Back to Case: {!RMA__c.Case_Number__c}</apex:outputLink>
</apex:pageBlock>
<apex:pageBlock title="Create RMA">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Caller Details" columns="1" collapsible="false">
<apex:inputField required="true" value="{!RMA__c.First_Name__c}" label="First Name"/>
<apex:inputField required="true" value="{!RMA__c.Last_Name__c}" label="Last Name"/>
<apex:inputField required="true" value="{!RMA__c.Phone__c}" label="Phone #"/>
<apex:inputField required="true" value="{!RMA__c.Email_Address__c}" label="Email Address"/>
<apex:inputField value="{!RMA__c.Case__c}" label="Case Number"/>
<apex:inputField value="{!RMA__c.PO_Number__c}" label="PO Number"/>
<apex:inputField value="{!RMA__c.Account_Number__c}" label="Account Number"/>
<apex:inputCheckbox value="{!RMA__c.I_don_t_have_an_Account__c}" label="Don't have account">
<apex:actionSupport event="onchange" reRender="companyInfo"/>
</apex:inputCheckbox>
</apex:pageBlockSection>
<apex:pageBlockSection title="Company Details" columns="1" collapsible="true" id="companyInfo">
<apex:inputField value="{!RMA__c.Company_Name__c}" label="Company Name"/>
<apex:inputField value="{!RMA__c.Street_Address__c}" label="Street Address"/>
<apex:inputField value="{!RMA__c.City__c}" label="City"/>
<apex:inputField value="{!RMA__c.State__c}" label="State"/>
<apex:inputField value="{!RMA__c.Zip_Postal_Code__c}" label="Zip/Postal Code"/>
</apex:pageBlockSection>
<apex:detail relatedList="false"/>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="RMA__c" >
<apex:form >
<apex:pageBlock >
<apex:outputLink value="/{!RMA__c.Id}" >Go Back to Case: {!RMA__c.Case_Number__c}</apex:outputLink>
</apex:pageBlock>
<apex:pageBlock title="Create RMA">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Caller Details" columns="1" collapsible="false">
<apex:inputField required="true" value="{!RMA__c.First_Name__c}" label="First Name"/>
<apex:inputField required="true" value="{!RMA__c.Last_Name__c}" label="Last Name"/>
<apex:inputField required="true" value="{!RMA__c.Phone__c}" label="Phone #"/>
<apex:inputField required="true" value="{!RMA__c.Email_Address__c}" label="Email Address"/>
<apex:inputField value="{!RMA__c.Case__c}" label="Case Number"/>
<apex:inputField value="{!RMA__c.PO_Number__c}" label="PO Number"/>
<apex:inputField value="{!RMA__c.Account_Number__c}" label="Account Number"/>
<apex:inputCheckbox value="{!RMA__c.I_don_t_have_an_Account__c}" label="Don't have account">
<apex:actionSupport event="onchange" reRender="companyInfo"/>
</apex:inputCheckbox>
</apex:pageBlockSection>
<apex:pageBlockSection title="Company Details" columns="1" collapsible="true" id="companyInfo">
<apex:inputField value="{!RMA__c.Company_Name__c}" label="Company Name"/>
<apex:inputField value="{!RMA__c.Street_Address__c}" label="Street Address"/>
<apex:inputField value="{!RMA__c.City__c}" label="City"/>
<apex:inputField value="{!RMA__c.State__c}" label="State"/>
<apex:inputField value="{!RMA__c.Zip_Postal_Code__c}" label="Zip/Postal Code"/>
</apex:pageBlockSection>
<apex:detail relatedList="false"/>
</apex:pageBlock>
</apex:form>
</apex:page>
You need to specify action attrobute on action support.based on the you retieve or query data from account.
Please check below sample code.
Hope this helps.
Thanks
Varaprasad