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
Nichelle HubleyNichelle Hubley 

Visualforce email template render name of related object, not the id

Hi, 

This is definitely a beginner level question, but I can't find the answer.

In my email I want to display the name of an account, not the ID.

The catch is that the vf email template references a custom object's related object that is AN account (the agency account), but not THE account the the object belongs to. 

Other solutions I found say to use Account.Name but that doesn't work in this case because it isn't the record's account I'm referencing. 

The visualforce code I'm using is: {!relatedTo.Agency2__c} 

I hope that question makes some sense. I'd be grateful for any help you can offer.

​Nichelle
Best Answer chosen by Nichelle Hubley
Alex KirbyAlex Kirby

Hi Nichelle,

Is it a lookup field? If so would something like {!Object.LookupObject__r.name} work?

If not can you post some code please?

Thanks,

Al
 

All Answers

Alex KirbyAlex Kirby

Hi Nichelle,

Is it a lookup field? If so would something like {!Object.LookupObject__r.name} work?

If not can you post some code please?

Thanks,

Al
 

This was selected as the best answer
Nichelle HubleyNichelle Hubley
Thanks Alex, {!relatedTo.Agency2__r.name} worked like a charm!