I have a child object of Parent Account name Vendor .
I want to create multiple vendor on one account record.
I have created master detail relationship between these two.
When i want to save(insert) the account i am getting the following error. at the line c.id=idey;
System.NullPointerException: Attempt to de-reference a null object
Code snippet in which error is as follows
public PageReference saveAccount(){
Database.SaveResult sr = Database.insert(acct, false);
Id idey=sr.getId();
List<Vendor__c> contactList=new List<Vendor__c>();
for(WrapperClass wc:lContacts){
Vendor__c c=new Vendor__c();
c.Name__c=wc.c.Name__c;
c.Email__c=wc.c.Email__c;
//c.Account__r.accountId =idey;
c.id=idey;
contactList.add(c);
}
insert contactList;
PageReference p = new PageReference('/001/o');
return p;
}
Can you help me out thanks in advance.