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
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12 

how do i add page table to visualforce page with clickable record row

Hi i have a simple table need to add to Contact object which will show top 5 cases from that contact sort by case number.

i need to create a visualforce page table to display 4 columns:

1) Case Number
2) Case Subject
3) Origin
4) Status

I wanted the Case Number to be clickable meaning if i click on the case number it will direct me to the case details

any suggestion?
Best Answer chosen by hy.lim1.3897974166558203E12
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Rplace your javascriot function with :
function OpenNewCaseDetailTab(theId, name) {
       sforce.console.openPrimaryTab(null, '/' + theId, true, name );
    }
cahnge method name to OpenNewCaseDetailTab and also remove semicolon added at the end of fucntion.

Thanks,
N.J

All Answers

Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Hi,

You can do somthing like this in your vf page:
<apex:pageBlockTable value="{!lstCases}" var="oCase">
          <apex:column  headerValue="CaseNumber" >
              <apex:commandLink value="{!oCase.CaseNumber}" action="/{!oCase.Id}"/>
              </apex:column>
          <apex:column value="{!oCase.Subject}"/>
          <apex:column value="{!oCase.Origin}"/>      
         <apex:column value="{!oCase.Status}"/>      
 </apex:pageBlockTable>

Where lstCases will populated in your controller.
Mark this as best answer, if this helps you.


Thanks,
N.J
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12
Hi NJ,

Thanks for the suggestion, i manage to show the results i want. however it does not open a new tab in my console, instead it changes the VF page to case details page. I would like to open a new tab upon clicking on the case number.
vmanumachu1.393650924860069E12vmanumachu1.393650924860069E12
Just add the target attribute to <apex:commandLink> tag. 

<apex:commandLink value="{!oCase.CaseNumber}" action="/{!oCase.Id}" target="_blank"/>
Mani RenusMani Renus
Use target attribute

<apex:commandLink value="{!oCase.CaseNumber}" action="/{!oCase.Id}" target="_blank"/>


Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
hi,

You can refer to http://www.salesforce.com/us/developer/docs/api_console/index.htm for opening any link in new tab for Salesforce Console.

Thanks.
hy.lim1.3897974166558203E12hy.lim1.3897974166558203E12
i tried this but when i click the case number, nothing happen

this is my code:

<apex:page standardController="Contact" extensions="sampleOutput5Cases">
     
     
    <apex:includeScript value="/support/console/29.0/integration.js"/>
    <script type="text/javascript">
     
        // Opens a subtab when a related Case Number is clicked
      function OpenPrimaryTab(theId, name) {
                       sforce.console.openPrimaryTab(null, '/' + theId, true, name, openSuccess, 'CustomerTab');
                   };
     </script>
  
  <apex:form >
  <apex:pageBlock >
  <apex:pageBlockTable value="{!ca}" var="oCase">
          <apex:column headerValue="CaseNumber" >
              <a HREF="#" onClick="OpenPrimaryTab('{!oCase.Id}','testname'); return false" >{!oCase.CaseNumber}</a>
          </apex:column>
          <apex:column value="{!oCase.Subject}"/>
          <apex:column value="{!oCase.Origin}"/>      
         <apex:column value="{!oCase.Status}"/>      
 </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
     
    
</apex:page>

Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Rplace your javascriot function with :
function OpenNewCaseDetailTab(theId, name) {
       sforce.console.openPrimaryTab(null, '/' + theId, true, name );
    }
cahnge method name to OpenNewCaseDetailTab and also remove semicolon added at the end of fucntion.

Thanks,
N.J
This was selected as the best answer