function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jarrodmichaeljarrodmichael 

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!

jhenningjhenning

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.