You need to sign in to do that
Don't have an account?
Help on Apex code that copy parent address to chlild adddress
HI,
Iam writing Apex code to create new contact record,when i select the parent account the address of selected account should copy to contact address fields in edit page itself.
I wrote some code :
vf:
-------------------------------
<apex:page sidebar="false" Controller="cont">
<apex:form >
<apex:inputfield value="{!con.accountid}">
<apex:actionSupport event="onchange" action="{!getrec}"/>
</apex:inputField>
</apex:form>
</apex:page>
class:
-------------------------------------------------------
public class cont {
public contact con {get; set; }
public PageReference getrec() {
if(con!=null){
contact cc=[select id,name from contact where id=:con.accountid ];
}
return null;
}
}
Getting following Error:
------------------------------------------------
System.NullPointerException: Attempt to de-reference a null object
Please look at the similar post.
Similar Post
This should solve your issue. You are not initializing the contact record. Please use Constructor to initialize the records.