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 :
VFP:
<apex:page standardController="Case" extensions="contrlller">
<apex:form >
<apex:pageblock >
<apex:pageBlockTable value="{!relatedCases}" var="val">
{!Case.AccountId}
<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() {
sforce.console.getFocusedPrimaryTabId(getCaseId);
}
var openSubtab = function openSubtab(result) {
var primaryTabId = result.id;
sforce.console.openSubtab(primaryTabId , '/' + {!val.Id}, false,
"{!val.CaseNumber}", null, null);
};
</script>
<body onLoad="Init()"/>
</apex:column>
<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>
<apex:column value="{!val.RecordTypeId}"/>
<apex:column value="{!val.Case_Type__c}"/>
<apex:column value="{!val.OwnerId}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
controller:
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)]){
conList.add(relatedCase);
}
return conList;
}
}