With my code i want to display related Cases on my Case page. Everything is working as expected but when i click on Case number(link) it opens in new tab in my browser. Can't get why my openSubTab is not working well. So my question is what to do to open Case in new Console subtab. Problem is in first column.

Here is what i got :


    <apex:page standardController="Case" extensions="contrlller">

   <apex:form >
    <apex:pageblock >
       <apex:pageBlockTable value="{!relatedCases}" var="val">

 <apex:column headerValue="CaseNumber">

<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">  
  function openNewSubtab() {
 var openSubtab = function openSubtab(result) {

            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , '/' + {!val.Id}, false,
                "{!val.CaseNumber}", null, null);
    <body onLoad="Init()"/>

         <apex:facet name="header"><apex:outputText value="Open Customer Service Cases " style="color:red"/></apex:facet>          
         <apex:column headerValue="CaseNumber">     
         <apex:commandLink value="{!val.CaseNumber}" action="/console?{!val.Id}" target="_blank" />
         <apex:column value="{!val.RecordTypeId}"/>      
         <apex:column value="{!val.Case_Type__c}"/>
         <apex:column value="{!val.OwnerId}"/>



public with sharing class contrlller{
    public Id Current_Acc_Id {get;set;}

    public contrlller(ApexPages.StandardController controller) {
        Case caseObject = (Case)controller.getRecord();
        Current_Acc_Id = caseObject.AccountId;

    public List<Case> getrelatedCases(){
        List <case> conList = new List<Case>();
        for(Case relatedCase: [SELECT CaseNumber, Case_Type__c, OwnerId, Origin, Id FROM Case WHERE (RecordTypeId != '01220000000VD9K' AND IsClosed!=True AND AccountId =:Current_Acc_Id)]){
        return conList;

1 Answer 1


Got this with code

> <script type="text/javascript">           
>         function openSubTab(recId){
>             var redirectUrl = recId;
>             if (sforce.console.isInConsole()) {
>                 sforce.console.getEnclosingTabId(function(enclosingResult){
>                     sforce.console.getEnclosingPrimaryTabId(function(primaryResult){
>                         sforce.console.openSubtab(primaryResult.id, redirectUrl, true, '', null);
>                     });
>                 });
>             } else {
>                 window.top.location.href = '/'+redirectUrl
>             }
>         }        
>     </script>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .