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
Bryn JonesBryn Jones 

Get Opportunity Contact Name on VF Page


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?


Bryn Jones
Use below. Also make sure you query this feild in conttoller SOQL
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 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"