You need to sign in to do that
Don't have an account?
mayrich1
Inserting New Custom Objects Records
Hi,
I have created a custom object that has a couple text and picklist fields on it. The custom object is a child of the Opportunity object. Whenever an opportunity is created I would like to automatically create a couple new custom objects with the same data in them every time. Any sample code to get me started would be greatly appreciated.
Thank you
Your code should look something like the following (warning: this code has not been tested):
All Answers
You'll want to create a trigger that fires whenever a new Opportunity is created. The Apex Reference guide has more than enough code to get you going. You'll also want to ensure that it supports bulk processing.
Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com
Thank you for the response Jeff. I looked through the manual and I did not see an example that showed how to automatically add records for a child custom object to the opportunity record every time an opportunity record has been created. I am familiar with creating new records, but I am not sure how to relate the custom object records to the opportunity record. Does it do this automatically since the trigger kicks off from the opportunity?
Thank you,
Ben
Your code should look something like the following (warning: this code has not been tested):