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
Rachel KrzyzanowskiRachel Krzyzanowski 

Help with an Apex Trigger to pull an Opportunities' Account's address & contact's information (like name & email address) into an email template to then use that in an email alert?


I need help creating an Apex Trigger in order to bring in a merge field into an email template. 

When Opportunities become "Closed Won", I want to create an email template (and then an alert) that would pull in the Account Billing Address on that Opportunity as well as the Main Contact's Name, Phone Number, and Email Address into the email.

When I reached out to Sales Support about this, they told me that I would need set up an Apex trigger to query the contact role then get the value from there.. because contact role is a junction object.

Can anyone offer any assistant to me with this? I would greatly appreciate it!!

HI Rachel Krzyzanowski,

You need to write trigger and inside the trigger you can create Email Body with the required details and then send email .

Please check this and let me know incase any .

Thanks ,