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
Nick G.Nick G. 

Lookup field value shows as ID Number instead of text



I am using the below email template to send an email to the primary contact of an opportunity once the opportunity has reached a certain stage. I added a contact lookup field to the Opportunity object so that the contact could be shown. The trouble is that when the email is sent, it doesn't send the contacts name rather the id


<messaging:emailTemplate subject="Equipment Order Confirmation" recipientType="Contact" relatedToType="Opportunity">

<messaging:htmlEmailBody >
    <STYLE type="text/css">
           TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
           TD  {font-size: 11px; font-face: verdana }
           TABLE {border: solid #CCCCCC; border-width: 1}
           TR {border: solid #CCCCCC; border-width: 1}
        <font face="arial" size="2">
          <p>Dear {! Relatedto.Contact__c},</p>
          <p>The following is a confirmation of your equipment order:</p>
          <p>Pickup Date: {! RelatedTo.Pick_Up_Date__c}</p>
          <p>Return Date: {! RelatedTo.Return_Date__c}</p>
          <p>Pickup Location: {! RelatedTo.Pick_Up_Location__c}</p>
            <table border="0" >
                <tr >
            <apex:repeat var="cx" value="{!relatedTo.OpportunityLineItems}">


Here is an example of what was sent:


Dear 003C000001IDKYcIAP,

The following is a confirmation of your equipment order:

Pickup Date: Fri Feb 24 00:00:00 GMT 2012

Return Date: Tue Feb 28 00:00:00 GMT 2012

Pickup Location:



AED Trainer (Generic)


Kyle Manikin


Bandage & CPR Training Kit


Adult Annie Manikin


Best Answer chosen by Admin (Salesforce Developers) 

Try this



All Answers


Instead of using {!Relatedto.Contact__c}, try {!recipient.Name}


Try this



This was selected as the best answer
Nick G.Nick G.

Thanks New_Developer! That worked perfectly. How did you know to use _r instead of _c?