Is there anyway to disable the link from the apex:outputField when using it in an email template?


<apex:repeat value="{!relatedto.RTS_Items__r}" var="o">

<b>Product Code:</b>&nbsp;

                    <apex:outputField value="{!o.SKU__c}"/><br/>

     <apex:outputField value="{!o.Item__c}"/><br/>

O.item is of type 'reference' and on the email it displays the item name but also creates it as a link to the item itself. I cannot just get the name unless I go through another lookup and I would like to avoid that.

Any suggestions?


Change the <apex:outputField> to an <apex:outputText>, and the email shouldn't populate the link. However, the link will not be displayed on the Page also. You could always re-populate the link pretty easily with jQuery on the VF page if need be.

(On a page I use externally in a Site, I used <apex:detail> to easily show the Page Detail for a record (without the work or re-creating a custom VF layout), but I had to remove all those links from lookup fields (cause the links didn't work in the Site context). And it wasn't too difficult once I got familiar with jQuery)


Lookup Fields are a special sort in Salesforce. When you reference one in a apex:outputField on a VF page (like your example <apex:outputField value="{!o.Item__c}"/>), the VF page display's o.Item__r.Name but with a link to the record (of the form '/o.Item__c'). Since you only need the name and not the link, just pull the name:

Ex. <apex:outputField value="{!o.Item__r.Name}"/>

Be sure to query this field first in your controller!

  • Thanks for your help Amator, when changing it to OutputText it only gives me the reference and not the description. I am looking for just the description without the hyperlink.
    – jnoel10
    Oct 16 '13 at 18:14
  • try this: <apex:outputField value="{!o.Item__r.Name}"/> You'll need to make sure the field `Item__r.Name" is queried before you can use it on the VF page. Oct 16 '13 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.