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

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:

When saving it reverts to this:


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,



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.


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

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.


The VF worked, stumbled across the "escape=true" issue posted about here:


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

You can now use cross object fields in Salesforce email templates using a 3rd party addin. You can read more about it here (

Hope that helps!