You need to sign in to do that
Don't have an account?
bujji
How to add accountId to the List of Contacts
Hi Guys,
I have list of Contacts, i need to add accountId to these contacts and then insert. How we can do it.
I tried the below way but getting some error.
Account account = new Account([select Id from Account Limit 1]);
List<Contact> cons = new List<Contacts>();
for(List<Contact> c:cons){
c.add(account.Id);
}
insert cons;
Thanks,
Bujji
I have list of Contacts, i need to add accountId to these contacts and then insert. How we can do it.
I tried the below way but getting some error.
Account account = new Account([select Id from Account Limit 1]);
List<Contact> cons = new List<Contacts>();
for(List<Contact> c:cons){
c.add(account.Id);
}
insert cons;
Thanks,
Bujji
List<Contact> cons = new List<Contacts>();
for(Contact c:cons){
c.AccountId = account.Id;
}
insert cons;
IF it helps you than please mark it as a solution and ENJOY APEX