You need to sign in to do that
Don't have an account?
Displaying a lookup field's text values instead of it's ID on a VF page
Hi,
I've got an issue that I've yet to find a good solution. It seems that others have solved it for their needs, but for me, it continues to plague me. Here's the issue:
I have a VF page that prints out to PDF. The VF Page is using a standard controller for the Opportunity table. In my Opportunity table, I have a CUSTOM field (Customer_Contact__c) that's a lookup to a Contact record. Below is my VF code:
<apex:page standardController="Opportunity" recordSetVar="SelectedOpps" renderAs="pdf">
<apex:variable var="number" value="{!0}"/>
<apex:repeat value="{!selected}" var="SelectedOpp">
<apex:variable var="number" value="{!number + 1}"/>
<Scout9:StandardSheetLabel LabelNumber="{!number}" ProductName="5164" Brand="Avery" ShowBorder="false">
<br></br><br></br><br></br><br></br><br></br><br></br><br></br>
<table width="100%" height="100%" cellpadding="2">
<tr>
<td><apex:outputText value="{!SelectedOpp.Customer_Contact__c}"/></td>
</tr>
<tr>
<td><apex:outputText value="{!SelectedOpp.Account.Name}"></apex:outputtext></td>
</tr>
<tr>
<td><apex:outputText escape="false" value="{!SelectedOpp.Customer_Mailing_Address__c}"></apex:outputtext></td>
</tr>
</table>
</Scout9:StandardSheetLabel>
</apex:repeat>
</apex:page>
The code above will display the contact's ID value, which is great and all, but I need the contact's name, not the ID. Changing the above line to:
<td><apex:outputText value="{!SelectedOpp.Customer_Contact__c.Name}"/></td>
Only leads to the following error message:
"Error: Unknown property String.Name."
I've tried changing outputText to outputField, but that yields the name as a link, but I don't want a link. I just need to get the name value. Does anyone know what's going on? It would seem that the ".Name" notation only works for standard fields.
Help! ~ Thanks in Advance!
try
<apex:outputText value="{!SelectedOpp.Customer_Contact__r.name}"/>
All Answers
try
<apex:outputText value="{!SelectedOpp.Customer_Contact__r.name}"/>
OMG! I can't believe it's that simple of a solution! You're a lifesaver Starz26! Thank you so much for your contribution. Do you know where this is documented so that I can learn more?