+ Start a Discussion

Get value from lookup on an email template

Hi All,

I have a Visualforce email template which is using relatedToType="Idea". On the Idea object, I have a custom lookup field called Rocker__c (don't ask :smileyvery-happy:) which is a lookup to the User object. I want to return the name from the User object. I've tried {!relatedTo.Rocker__c.FirstName} and it didn't work saying

Error: Unknown property 'String.FirstName'
What am I missing?



Use Rocker__r for relationship traversing. The "__c" value is just the Id of the looked up object. Also make sure your SOQL explicitly queries the related object's fields that you reference.

Jeremy Kraybill
Austin TX

That worked, thanks! I didn't need to do anything with SOQL using the email template - I just changed the "c" to an "r" in Rocker__r