+ Start a Discussion

Trigger creation of child objects when Parent object is created

I am trying to come up with a way to Trigger Child Records to be created once the Parent is created based on certain criteria.


For example:

I create a Timesheet for the begin date of 5/10/2010 and end date of 5/25/2010.  I want to create a Time Entry(child record) for each date inside of that range.


Does anyone know if this is possible?  I know I could trigger a child record but wasn't sure if I could based on criteria.


Thanks for any help!


This is very doable. Just create an After Insert trigger on the parent that creates the children based on the data in the parent. In the trigger logic, use the Trigger.New list to access the parent objects.