Loading

Email template doesn’t merge the fields from a related list

Data pubblicazione: Jun 11, 2026
Descrizione

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.

Risoluzione

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:

Option 1: Custom Apex Class and Visualforce Email Template

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/.

Option 2: Add Lookup Fields to the Custom Object

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.

Numero articolo Knowledge

000385019

 
Caricamento
Salesforce Help | Article