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
sgoremasgorema 

Displaying a lookup field value in VisualForce

I have a VF page that is displaying Quote data. On our custom quote object we have a lookup to the Contact object to store the person who is designated as the System Admin. The field is called System_Admin__c. I need to display this person's name on in a table on the page and thought I could do so by specifying:
 
Code:
<table border = "1">
            <tr>
                <td width=20%>Name:</td>
                <td width=30%>{!SFDC_520_Quote__c.System_Administrator__c}</td>
                <td width=20%>Phone:</td>
                <td width=30%><apex:outputtext value="{!SFDC_520_Quote__c.System_Administrator_Phone__c}" /></td>
            </tr>

 
but this displays the id of the contact record instead of displaying the contact's name. How do I get the Contact name to display?
jwetzlerjwetzler
use apex:outputField


Message Edited by dchasman on 06-20-2008 07:08 PM
sgoremasgorema
actually, i tried it both ways..with and without apex:output and both ways showed the record id...
dchasmandchasman
{!SFDC_520_Quote__c.System_Administrator__c.name}
mtbclimbermtbclimber
Doug's solution will definitely work as well but I don't understand why outputField does not work for you. The following page markup returns the expected result here:

Code:
<apex:page standardController="Contact">
    <apex:panelGrid columns="1">
        <apex:outputField value="{!contact.accountid}"/>
        <apex:outputField value="{!contact.Test__c}"/>
        <apex:outputField value="{!contact.Contact__c}"/>
  </apex:panelGrid>
</apex:page>

 Test__c is a lookup to a custom object and Contact__c is a lookup to Contact.

Screenshot below.



Message Edited by mtbclimber on 06-21-2008 09:04 AM