Hi,Please do the changes in your class as mention below
Thanks,Keyur Modipublic class AccountDisplay {
public account acc {get; set;}
public contact con {get; set;}
public AccountDisplay (){
con=new contact();
acc=new Account();
}
public pagereference getdetails(){
system.debug('ccc=='+con);
acc = [select id, name from account where id = :con.AccountId];
return null;
}
}
Hi,
Only one diffrance between my code and your code is you had not created the instance of the two object contact and account ... and so i create the instace of both oject in constructor so whenever your page load it will create instace for both object. so it will not give the error which you faced before.i hope this clarification will make your doubt clear .. if still you have any confusion feel free to ask,Thanks,Keyur Modipublic class AccountDisplay {
public account acc {get; set;}
public contact con {get; set;}
public AccountDisplay (){ // here I created constructor for this class
con=new contact(); // I create the instance of contact
acc=new Account(); // I create the instance of Account
}
public pagereference getdetails(){
system.debug('ccc=='+con); // This is to just check either value in con.account.id is comming or not so that account query will work properly
acc = [select id, name from account where id = :con.AccountId];
return null;
}
}
Hi,Thanks for your reply. It worked. However, can you please explain your code especially the system.debug part.Thank you,Satya
5 answers