I have requirement that i need to open the list of cases associated to an account in a sub tab by clicking on a button in account detail page. I have written the following visualforce page to accomplish this task. As of now, I have hardcoded the id values. Could anyone one please tell me how to open multiple subtabs at a time for a primary tab in console ?
<apex:page standardController="Case">
<A HREF="#" onClick="callMultipleSubTabs();return false">
Click here to open a new subtab</A>
<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript">
var strURL;
var strTitle;
function callMultipleSubTabs()
{
var caseIds = "5009000000VxOsE;5009000000VxOsD";
var caseTitle = "00001001;00001000";
var id = caseIds.split(";");
var title = caseTitle.split(";")
var finalId = caseIds.replace(";","|");
for(i=0;i<id.length ; i++)
{
if(sforce.console.isInConsole())
{
alert('In console');
testOpenSubtab(caseId,caseNumber);
}
else
{
window.open("/"+id[i],'_blank');
window.focus();
}
}
}
function testOpenSubtab(inputURL,inputTitle) {
strURL = inputURL;
strTitle = inputTitle;
//First find the ID of the primary tab to put the new subtab in
sforce.console.getEnclosingPrimaryTabId(openSubtab);
}
var openSubtab = function openSubtab(result) {
//Now that we have the primary tab ID, we can open a new subtab in it
var primaryTabId = result.id;
sforce.console.openSubtab(primaryTabId , strURL, false,
strTitle, null, openSuccess, strTitle);
};
var openSuccess = function openSuccess(result) {
//Report whether we succeeded in opening the subtab
if (result.success == true) {
alert('subtab successfully opened');
} else {
alert('subtab cannot be opened');
}
};
</script>