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
abdnabdn 

How to include fields of related object in Mail Merge template?

I am creating a mail merge template on opportunity. On Opportunity, we have a custom Account lookup field named Supplier Name (API name is SupplierName__c). I want to include this Account fields like Phone, Address etc in the mail merge template but I am not able to do this.

I can display Supplier Name (like this <<Opportunity_SupplierName>> ) but cannot retrieve other fields. To display phone, I tried this:

<<SupplierName_Phone >>

<<Supplier_Name_Phone>>

<<Opportunity_SupplierName_Phone>>

<<Opportunity_Supplier_Phone>>

Any Idea how it should be done?
Arunkumar RArunkumar R
Hi,

For getting related object fields use visualforce template and find the below sample code,
 
<messaging:emailTemplate subject="Sign the Agreement" relatedToType="Contact">
<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
{!relatedTo.Account.Name}
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Where relatedToType is Contact object and i am binding contact related account name by using {!relatedTo.Account.Name} Syntax.

For your case, try the below,

relatedToType - Opportunity 

{!relatedTo.SupplierName__r.Name}  --> Dynamic Binding

SupplierName__r is the relationship name. Just ensure your relationship name.
abdnabdn
Hello Arun,

I am creating a mail merge template which is not accepting the dot notation. Here is introduction of mail merge: https://help.salesforce.com/HTViewHelpDoc?id=mailmerge.htm