A merge field is a placeholder in a Salesforce email template that pulls data from a record field at the time the email is sent. For example, {!Contact.FirstName} inserts the contact's first name into the email body.
Salesforce email templates support merge fields only from records that have a direct lookup relationship to the record the template is based on. A related list represents a one-to-many relationship, meaning multiple child records can be associated with a single parent. Because multiple records can exist in a related list, the system cannot determine which record to pull into the template, and it is also not possible to merge all records at once.
For merge fields to work, the template must reference a field through a lookup field on the parent object — similar to how a Contact record has a lookup to its parent Account, enabling {!Contact.Account.Name} to work correctly.
Note: Merge fields from custom fields will not work if the primary object does not have a direct relationship with the object that custom field belongs to.
Example: A template on the Lead object cannot merge {!User.Signature__c} because Lead does not have a direct lookup to User.
To learn how to create lookup relationships, see Define Lookup Filters.
Because Salesforce email templates support only one-to-one relationships (via lookup fields), they cannot directly pull data from a related list (one-to-many). The following workarounds are available:
A developer can create an Apex Class that queries all records in the related list and injects them into a Visualforce email template. Note that recipients of a Visualforce email must be able to log in to your Salesforce org to view the template, which limits the scalability of this option for external recipients. For developer assistance, consider posting on Salesforce Developers https://developer.salesforce.com/.
Instead of using the related list, create a lookup field on the parent object that points directly to the custom object record you want to merge. You need one lookup field for each custom object record you want to include in the email template.
Important: This approach is only practical when the number of related records is small. For example, if a Contact may have 20 or more related Orders, creating 20 lookup fields (Order 1, Order 2, Order 3…) is not advisable. If only one or two records need to be merged at a time, create one or two lookup fields and manually populate them from the related list based on your needs at the time of sending. Then update your email template to reference those lookup fields.
000385019

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.