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
hramanihramani 

Email template merge fields not appearing

I have a custom email template where there are merge fields like below.

{!Contact.AccountId}
{!Contact.Id}
{!Contact.Name}
{!Application__c.Name}
{!Application__c.Contact__c}

But when I preview using a single Contact, ideally I need all the merge fields to be populated but only Contact id and Contact name are appearing.
Application is a child object of Contact. One Contact can have one application. Not only Application other child object details are also not populating if I enter them as merge fields.

How do I get the related child object details on the email template
Please help
Khan AnasKhan Anas (Salesforce Developers) 
Hi Hramani,

Greetings to you!

Cross-Object Email Template is not Possible in salesforce at this point in time. There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.

https://success.salesforce.com/ideaView?id=08730000000Brk7AAC

You can't access or use the values of any related object in email templates, you might have to create a formula field to bring down the value from parent to the object on which the email template is target.

You can access and display child record details in the email template of a parent is to use Visualforce Email Templates.

https://salesforce.stackexchange.com/questions/95408/access-child-objects-fields-in-visualforce-email-template

http://www.infallibletechie.com/2013/05/visualforce-email-template-with-custom.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas