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

Mapping of field in lookup



I made one VF page, code given below. My requirement is when user select any record from look up(Site_Address__c), the value of some field from Site address should map to some fields in Contact, as "Street"which is in Street Adress, should populate in "Mailing Street" of contacts. I dont want this when user save the record(as it can be done by trigger), I want as soon user chose any record, correspond to that record value should populate.(By onchange).


Can any one provide me soln for this with sample code?


<apex:page standardController="Contact" >

    <apex:form >
        <apex:pageBlock >

                    <apex:pageBlockSection title="Address Information" columns="2">
                    <apex:outputPanel layout="block"> 
                    <label for="checkbox">Select address from existing address </label> 
                    <input id="checkbox" type="checkbox"/> 
                     <apex:inputField value="{!contact.Site_Address__c}" />                   


                <apex:inputField value="{!Contact.MailingStreet}"/>
                <apex:inputField value="{!Contact.MailingCity}"/>
                <apex:inputfield value="{!Contact.MailingState}"/>
                <apex:inputfield value="{!Contact.MailingPostalCode}"/>
                <apex:inputfield value="{!Contact.MailingCountry}"/>

            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>



Hengky IlawanHengky Ilawan

I think you can use javascript remoting call from the Site_Address__c lookup and populate those fields.


pls provide sample code for this...



Hengky IlawanHengky Ilawan

Hi @taani,


There is a good example from salesforce documentation