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
MissyLewMissyLew 

Trigger to update lookup field on custom object records on Opportunity after creating a Quote

I have a custom object called "Location" with a master-detail relationship to Opportunity and a lookup relationship to Quote. When I create a quote from the opportunity, I would like to populate all location records on the Opportunity with the new Quote ID. We need to do this so that I can display the Location records on the Quote Template (PDF). 

I think I need an after insert trigger on Quote so once I save the quote, the trigger will grab all Location records where the Location Opportunity ID = Quote Opportunity ID, then populate Quote ID on the Location records in the retrieved list. I'm not a developer so am hoping someone can help! Thanks in advance for any help you can offer.
sraju1.3907075653576648E12sraju1.3907075653576648E12
Hi Missy Lew,

I understand you have not written salesforce code before so would like you to go thorugh the following blog which explains very simply how you can write a trigger on any object - it has sample code which you can try on your ORG to get an understanding of what trigger can do.

http://shivasoft.in/blog/salesforce/step-by-step-salesforce-tutorial-%E2%80%93-creating-trigger-and-test-cases-%E2%80%93-6-of-6/

I would encourage you to start and any questions or issue you face - just paste the code and the community will help you solve the errors :)

Happy learning!