You need to sign in to do that
Don't have an account?
Sv Krishna Reddy
issue with insert con
public class Test_Contact {
public Account acc {set;get;}
public Contact con {set;get;}
public Test_Contact(){
acc=new Account();
con=new Contact();
}
public void create(){
insert acc;
con.AccountId=acc.id;
insert con;
}
}
public Account acc {set;get;}
public Contact con {set;get;}
public Test_Contact(){
acc=new Account();
con=new Contact();
}
public void create(){
insert acc;
con.AccountId=acc.id;
insert con;
}
}
Please elaborate on the challenge/error you are facing
Please ensure whether you have an account inserted in the database before you pass an ID to the contact record while creating one,
Find an example over below link for similar functionality:
https://salesforce.stackexchange.com/questions/148974/inserting-accounts-and-contacts-simultaneously
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.
DML requires SObject or SObject list type: Contact