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
dmchengdmcheng 

Email template and related contact merge fields

I have a custom object that has a master-detail relationship with Contact.  I have a workflow rule on the custom object that needs to send an email to the contact.  In the email template I would like to include merge fields from the contact, such as FirstName.

I configured the email alert to use Related Contact and in the template I used the field {!Custom_Object__c.Contact__r.FirstName}, but the field is blank when I do a test.  Is this supposed to work in Salesforce, or can I only use fields from the object that fired the workflow rule?

I've tried a VF email template but I can't get it to work either.

Thanks
David

Best Answer chosen by Admin (Salesforce Developers) 
dmchengdmcheng

I found the answer - Even though it is a custom object workflow that is sending the email, I don't need to include any references to the custom object in the contact merge fields.  So I just use {!Contact.FirstName} as if the workflow were firing directly on the contact.

 

Thanks

 

All Answers

netTrekker_ADnetTrekker_AD

Is {!Custom_Object__c.Contact__r.FirstName} a real merge field value available to you in the template editor? If so, then it should work.

 

I do not have the same setup as you but I tried to create an email alert on a Quote anwith the intentions of including the name of the Contact related to the Quote on the email template, but there was no merge field value available to me for this. Quotes are not custom, so your situation may be different.

dmchengdmcheng

I found the answer - Even though it is a custom object workflow that is sending the email, I don't need to include any references to the custom object in the contact merge fields.  So I just use {!Contact.FirstName} as if the workflow were firing directly on the contact.

 

Thanks

 

This was selected as the best answer
netTrekker_ADnetTrekker_AD

Excellent. I was thinking that was how it works, because that is how Quotes work, but the whole custom object gave me the slight lack of confidence.


Glad you solved it!