+ Start a Discussion
domdickdomdick 

parent and child object insert

Hello,

 

I would like to insert parent and multiple child records in single click.

Basically, i am trying to create a parent VF page. So if the use hit "save" button then insert the parent record and insert multiple child records same time.

 

How can i solve this via apex class? Any example?

 

Thanks,

Dinesh

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I wrote a blog post on a very similar topic a while back:

 

http://bobbuzzard.blogspot.co.uk/2011/03/edit-parent-and-child-records-with.html

 

You'll need to tweak it to insert the parent record first, then set the parent id for each of the child records before inserting those.

 

 

All Answers

bob_buzzardbob_buzzard

I wrote a blog post on a very similar topic a while back:

 

http://bobbuzzard.blogspot.co.uk/2011/03/edit-parent-and-child-records-with.html

 

You'll need to tweak it to insert the parent record first, then set the parent id for each of the child records before inserting those.

 

 

This was selected as the best answer
Ankushs@lesforceAnkushs@lesforce

Good reply