+ Start a Discussion
rajasfdcrajasfdc 

can create 10contacts while create one new account?

can create 10contacts while create one new account?i mean to say when we created a new account at that time i wish to create 10 contacts at atime .how to do this .pls clarify.

thanks in advacne

 

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

 

account a=new account(name ='aa');

insert a;

list<contact> l1=new list<contact>();

for(integer i=0;i<10;i++)

{

    contact cc=new contact(lastname='cc',accountid=a.id);

    l1.add(cc);

}

insert l1;

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.