You need to sign in to do that
Don't have an account?
MrKen
Trigger to autocreate record in related list
Hello,
I searched around the forum/documentation to do this simple trigger update but didn't find anything.
What I have: 2 objects- Site Location & Opportunity. Site Location has a lookup to the opportunity.
What I'm trying to do: Since every opp in our instance should have a site location, I'd like for a site location to be automatically created (and linked) everytime a new opportunity is created.
Here's my code that I have so far:
trigger createSiteLocations on Opportunity (after insert) { for (Opportunity opp : trigger.new) { Site_Location__c sl = new Site_Location__c(); insert sl; } }
This is not working...any ideas/help?
You are not populating the lookup value on Site location. Also, collect site locations in a list and insert them in bulk to avoid hitting governor limits. Something like this would do -
All Answers
You are not populating the lookup value on Site location. Also, collect site locations in a list and insert them in bulk to avoid hitting governor limits. Something like this would do -
:smileyhappy:
Genius!! Thanks for your help. I see how the above breaks down...going to start creating more to help with processes!!
Thanks again!