+ Start a Discussion
ElectronElectron 

Visual force Email Template to get Related Object Name by Look-up field.

I am writing one Visual force Email template.

 

There is one field (Let's call it Field A) on the contact page, which is look-up field that link to account

I want to get the account name by field A, but I could only get the account's ID, right now. 

 

If this field link to another customed object, we can use

obj1__c.obj2__r

But in this scenario it's account, how could I get the Account Name? 

 

Also I think about to use SOQL, but is that right choice for Email Template?

 

I don't know if I explain it clearly, if not, I can write more, thank you for checking my question. 

 

Update 2013-05-14

 

Sorry I didn't explain it very well, in my template.

  • Recieve is User
  • Related object is Contact.

The field A is an look up field to account, I want to get the Account Name by field A. 

Best Answer chosen by Admin (Salesforce Developers) 
ziedzied

I had a similar case where i needed to display contact name in visualForce page i did:

{!RelatedTo.Contact__r.name} 


if you do "contact__c" it will show only the ID

Can you check and go back to me ? it works for me.

Zied.

All Answers

kiranmutturukiranmutturu

if it is relatedtype that you assigned to relatedToType in the <messaging:emailTemplate> tag then you are refering then some thing like this u can use
{!related.name}

ElectronElectron
sorry I already use contact as related object, it's not the solution I am looking for.

But I still want to thank you.
ziedzied

Hi Electron,

Have you found a solution for this ?

Zied.

ElectronElectron
Unfortunately not.
ziedzied

I had a similar case where i needed to display contact name in visualForce page i did:

{!RelatedTo.Contact__r.name} 


if you do "contact__c" it will show only the ID

Can you check and go back to me ? it works for me.

Zied.

This was selected as the best answer
ElectronElectron

Hi zied,

 

Sorry I replied you so late, your solution works perfect.  

Thank you so much.

ziedzied
you're Welcome :)