+ Start a Discussion
GMASJGMASJ 

How to make opportunity name as link using apex:outputField

Hi, 

 I am using <apex:outputField style="font-weight:500"  value="{!opportunity.name}"/> tag to display opportunity name for some reasons its not enabling the link to drill down the opportunity. 

Please suggest me how to enable the link. 

Thanks
Sudhir
Best Answer chosen by GMASJ
Dilip_VDilip_V
Sudhir,

Have you tried this
<apex:outputLink value="https://ap2.salesforce.com/{!opportunity.Id}" id="theLink">{!opportunity.name}</apex:outputLink>
Make sure to populate your instance in place of ap2.salesforce.com

Let us know if you have any issues.

Mark it as best answer if it works.
Thanks.
 

All Answers

Dilip_VDilip_V
Sudhir,

Have you tried this
<apex:outputLink value="https://ap2.salesforce.com/{!opportunity.Id}" id="theLink">{!opportunity.name}</apex:outputLink>
Make sure to populate your instance in place of ap2.salesforce.com

Let us know if you have any issues.

Mark it as best answer if it works.
Thanks.
 
This was selected as the best answer
ManojjenaManojjena
HI Sudhir,

Create a formula field and use that in the page .Add below formula in the field .
 
HYPERLINK( LEFT( $Api.Enterprise_Server_URL_25 , FIND('/', $Api.Enterprise_Server_URL_25, 9) ) + Id, Name)

Let me know if it helps !!
Thanks 
Manoj
Lalit Mistry 21Lalit Mistry 21
Hi Sudhir,
<apex:outputLink value="/{!opportunity.Id}" id="oppRecord">{!opportunity.name}</apex:outputLink>
Output link with relative path to opportunity id should work for you without having to worry about the instance of your org and thereby reducing an overhead of manual changes during deployment.
GMASJGMASJ
Thanks you all for you repsonce I am currently using the below code problem am facing is am using <apex:outputField> in all the items since i wanted opportunity as link am not able get in <apex:outputField 

 Alignments are properly made in <apex:outputField> is there way we can use <apex:outputField> for link as well please let me know
 
<apex:outputLabel value="Opportunity Name :"  style="font-weight: bold; text-align: center;">
           <a href="/{!opportunity.id}">{!opportunity.Name}</a> 
           </apex:outputLabel>


Thanks

Sudhir