+ Start a Discussion
Bryn JonesBryn Jones 

Get Opportunity Contact Name on VF Page

SF DEV's

I am trying to retrieve the Full Name of an Opportunities Contact in a VF page. I have {!Opportunity.Opportunity_Contact__r} right now but it brings up the Contact ID instead. What am I doing wrong or what do I need to do?

Thanks,

Bryn Jones
venkat-Dvenkat-D
Use below. Also make sure you query this feild in conttoller SOQL
 {!Opportunity.Opportunity_Contact__r.Name} 
SabinaSabina
Hi Bryn,

Try {!Opportunity.Opportunity_Contact__r.FirstName & ' ' & Opportunity.Opportunity_Contact__r.LastName}
'__r' is for object relationships and it allows you to retrieve data from the related record, but you also need to mention the field you need from that record.

Hope it helps   
Dianna Raquel Perez GüerequeDianna Raquel Perez Güereque
When you have a "search" field, when pointing it (without the "r" or not specifying any other value)  you would get the ID of the related object.
When using the field__r.name you would get the value on the "name" standar field. 
Check out the standar fields in contact and just bring them with the "object.searchfield__r.fieldnameoftherelatedobject"