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
Francesco SciutoFrancesco Sciuto 

How to open a new sub tab in Sales Console

I have a Visualforce page correctly displayed in Sales Console as sub tab of Live Agent session and among other things I need to open a new sub tab when the user clicks a button of the VF page. So according to the documentation I created a button on my Visualforce page, I tight the Javascript funciton openNewSubTab to the onClick event and I placed the code to open an additional sub tab. The Javascript looks like this:
 
<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript"> 

function openNewSubTab(){

console.log('Inside the main function');
sforce.console.getEnclosingPrimaryTabId(function(result) {
     console.log('Inside the new tab function');
     var primaryTabId = result.id;
     sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 'salesforce', null, null, null);
});

</script>

This code does not work. In the console I just see the output 'Inside the main function' but not the text placed inside the callback function of sforce.console.getEnclosingPrimaryTabId(). I also tried to declare the callback separately as indicated in the documentation (see below) but I cannot make it work. Am I missing something?
<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript"> 

var openSubTab = function(result){
    console.log('Inside the new tab function');
     var primaryTabId = result.id;
     sforce.console.openSubtab(primaryTabId , 'http://www.salesforce.com', false, 'salesforce', null, null, null);
}

function openNewSubTab(){

console.log('Inside the main function');
sforce.console.getEnclosingPrimaryTabId(openSubTab);

</script>



 
Francesco SciutoFrancesco Sciuto
Solved, the version of the integration script was outdated. Current is 38

<apex:includeScript value="/support/console/38.0/integration.js"/>