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
TehNrdTehNrd 

Cross object values in a email template?

Is it possible to have a cross object value in an email template? On the Lead object I have a lookup field (Primary_Contact__c) to a user. Is there anyway to get user fields on this template with workflow from the Lead object.

I have tried with no luck:
{!Lead.Primary_Contact__c.Title}
{!Lead.Primary_Contact__r.Title}

When saving it reverts to this:
{!Lead.Primary_Contact__c}
{!Lead.Primary_Contact__r}

Thanks,
Jason
shillyershillyer

Hi Jason,

Since you have a lookup to User, you can create cross object formula fields that pull data from the User fields. Then these custom fields can be in your email template.

Hope that helps,

Sati

shillyershillyer

Another option is also using Visualforce Email Templates. The email template is a visualforce page using the messaging:emailTemplate component. You can then set the relatedToType attribute to User to pull cross object data using {!relatedTo.XXX} tag.

Best,
Sati
GoForceGoGoForceGo

I cannot make this work either using standard e-mail templates.


If workflow rule is defined on Object X which has master or lookup relationship to Object Y, and if I use

 

X.Y__r.FieldName, I get blank in the actual e-mail.


 

 

 

 

Message Edited by GoForceGo on 03-10-2010 12:52 PM
fgwarbfgwarb

Hello All,

 

We're just about to try the VF template approach, but I was curious if anyone was able to get the cross-object field thing working...

 

Will post with results of the VF attempt.

fgwarbfgwarb

The VF worked, stumbled across the "escape=true" issue posted about here: http://boards.developerforce.com/t5/Visualforce-Development/Rich-Text-Area-fields-do-not-display-correctly-in-Visualforce/m-p/184507

 

Other than that this was a pretty quick work-around.

spielsspiels
You can now use cross object fields in Salesforce email templates using a 3rd party addin. You can read more about it here (http://www.contactmonkey.com/blog/cross-object-fields-in-salesforce-email-templates-fixed).

Hope that helps!