+ Start a Discussion
Nisar AhmedNisar Ahmed 

Creating multiple child records for a parent object in a VF page in one shot.



I have 2 custom objects 'Parent__c' and 'Child__c'. Have created a look up on parent object.

I have created a VF page containing fields of both the objects. Now, I need to create one Parent object record and multiple child records(say 2-5 records with different user input data for each child record) associated with the parent record in one shot when I click on 'Save' button.


Please let me know if you have any idea or work around to accomplish the above scenario.

Any help on this will be highly appreciated.


Your look-up relationship will work fine as Lookup is (1:n) kind of relationship.

But if your parent is deleted then child wont be affected in this. If you want that child should also be deleted when parent is deleted then create a Master-detail relationship.


In your child record create desired input data like UserName__c, EmailId__c and a look-up or master detail relationship with Parent__c. This all data of Child__c will be linked with your parent object automatically when you hit save(insert in database) button.