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
cFangcFang 

Adding Hyperlinks to a Custom Related List

I have a custom related list that I have setup with the APEX page code below. The problem is that the custom related list does not include hyperlinks to the related items. In this case, I have created a custom list that displays opportunities that are associated with the same account as the contact is. The problem is that a user cannot click the associated opportunity and navigate to that page. What do I need to add to get hyper link functionality? Any help is greatly appreciated.

 

<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
<style>
.fewerMore { display: none;}
</style>
<apex:form > 
 <apex:pageMessages /> 
 <apex:detail relatedList="true"></apex:detail>
 <apex:pageblock id="CustomList" title="Related Opportunities"  >   
     <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
             <apex:column value="{!o.Name}"/>        
             <apex:column value="{!o.Account.Name}"/>        
             <apex:column value="{!o.Type}"/>       
             <apex:column value="{!o.Service_MRR__c}"></apex:column>       
             <apex:column value="{!o.CloseDate}"/>   
          </apex:pageBlockTable>   
          <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> 
      </apex:pageblock>
   </apex:form>
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
kkr.devkkr.dev
<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
<style>
.fewerMore { display: none;}
</style>
<apex:form > 
 <apex:pageMessages /> 
 <apex:detail relatedList="true"></apex:detail>
 <apex:pageblock id="CustomList" title="Related Opportunities"  >   
     <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
            <apex:column Headervalue="Opportunity Name">
                 <apex:outputlink value="/{!o.Id}" target="_parent">
                 <apex:outputText value="{!o.Name}"/>
                 </apex:outputLink>
</apex:column>
 <apex:column value="Account Name">
<apex:outputlink value="/{!o.Account.Id}" target="_parent">
<apex:outputText value ="{!o.Account.Name}"/>
</apex:outputlink>
  </apex:column>
  <apex:column value="{!o.Type}"/> <apex:column value="{!o.Service_MRR__c}"></apex:column> <apex:column value="{!o.CloseDate}"/> </apex:pageBlockTable> <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> </apex:pageblock> </apex:form> </apex:page>

All Answers

kkr.devkkr.dev

Hi CFang,

 

 Use below  format to display hyperlinks.

 

<apex:column headerValue="Opportunity Name">
            <apex:outputlink value="/{!o.Id}" target="_parent">
             <apex:outputText value="{!o.Name}"/>
            </apex:outputLink>
   </apex:column>

 

Thanks

cFangcFang

I went ahead and inserted it but it still isn't working. Here is the code. What am I doing wrong?

 

<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
<style>
.fewerMore { display: none;}
</style>
<apex:form > 
 <apex:pageMessages /> 
 <apex:detail relatedList="true"></apex:detail>
 <apex:pageblock id="CustomList" title="Related Opportunities"  >   
     <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
             <apex:column value="{!o.Name}"/>
                 <apex:outputlink value="/{!o.Id}" target="_parent">
                 <apex:outputText value="{!o.Name}"/>
                 </apex:outputLink>        
             <apex:column value="{!o.Account.Name}"/>        
             <apex:column value="{!o.Type}"/>       
             <apex:column value="{!o.Service_MRR__c}"></apex:column>       
             <apex:column value="{!o.CloseDate}"/>   
          </apex:pageBlockTable>   
          <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> 
      </apex:pageblock>
   </apex:form>
</apex:page>

 

kkr.devkkr.dev
<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
<style>
.fewerMore { display: none;}
</style>
<apex:form > 
 <apex:pageMessages /> 
 <apex:detail relatedList="true"></apex:detail>
 <apex:pageblock id="CustomList" title="Related Opportunities"  >   
     <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
            <apex:column Headervalue="Opportunity Name">
                 <apex:outputlink value="/{!o.Id}" target="_parent">
                 <apex:outputText value="{!o.Name}"/>
                 </apex:outputLink>
</apex:column>
 <apex:column value="{!o.Account.Name}"/> <apex:column value="{!o.Type}"/> <apex:column value="{!o.Service_MRR__c}"></apex:column> <apex:column value="{!o.CloseDate}"/> </apex:pageBlockTable> <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> </apex:pageblock> </apex:form> </apex:page>
cFangcFang

Is it possible to do it for the Account name as well? As you can tell, I'm pretty new at this. Thank you for your help.

kkr.devkkr.dev
<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
<style>
.fewerMore { display: none;}
</style>
<apex:form > 
 <apex:pageMessages /> 
 <apex:detail relatedList="true"></apex:detail>
 <apex:pageblock id="CustomList" title="Related Opportunities"  >   
     <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
            <apex:column Headervalue="Opportunity Name">
                 <apex:outputlink value="/{!o.Id}" target="_parent">
                 <apex:outputText value="{!o.Name}"/>
                 </apex:outputLink>
</apex:column>
 <apex:column value="Account Name">
<apex:outputlink value="/{!o.Account.Id}" target="_parent">
<apex:outputText value ="{!o.Account.Name}"/>
</apex:outputlink>
  </apex:column>
  <apex:column value="{!o.Type}"/> <apex:column value="{!o.Service_MRR__c}"></apex:column> <apex:column value="{!o.CloseDate}"/> </apex:pageBlockTable> <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel> </apex:pageblock> </apex:form> </apex:page>
This was selected as the best answer
cFangcFang

Thanks for your help kkr.dev. I appreciate it. This is great.