4

Here is the VF page I am using to open a subtab in Service Cloud Console upon clicking a button. The subtab opens but another blank tab also opens that I am trying to get rid of.

Here is the problem: Screenshot of Extra unnecessary middle tab called salesforce.com

The middle salesforce.com tab is unnecessary and just a blank page. How do I make it not appear?

Here is the code:

<apex:page >

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

    <script type="text/javascript">

        window.onload = function(){
           testOpenSubtab();
        }

        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }

        var openSubtab = function openSubtab(result){
            var primaryTabId = result.id;

            sforce.console.openSubtab(primaryTabId , 'https://na1.salesforce.com/apex/service_cloud_console_flow_1', true, 
                'Add New Service');
        }
       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>

</apex:page>
  • Do you have an example of how you are calling this from the button? I'm not quite sure why you have a Visualforce page for a button click. – Mark Keats Mar 9 '15 at 13:10
  • remove window.onload = function(){ testOpenSubtab(); } – EricSSH Apr 11 '16 at 17:39
1

Old thread, but posting this for others unaware of the other solutions in this use case, and some general debugging tips for this type of issue.

The method used in the question should work, but is missing some parameters like the callback function for success and the override subtabid (or null if not overriding an existing subtab). This page is also using API 20 of the console kit which is fairly old at this point (not as much at original post, but still old).

Also, you can do some debugging in the openSubtab callback with console log to double check that the result coming to the openSubtab callback is containing a primary tab id. If that Id is null, I believe you'll see a brand new primary tab opened up (as you see here).

Example with openSubtab with all necessary params, updated console integration kit (API 36), and a sample console.log statement:

<apex:includeScript value="/support/console/36.0/integration.js"/>
<script type="text/javascript">

    function testOpenSubtab() {
        //First find the ID of the primary tab to put the new subtab in
        sforce.console.getEnclosingPrimaryTabId(openSubtab);
    }

    var openSubtab = function openSubtab(result){
        var primaryTabId = result.id;

        // good place to debug to see if we received a primary tab id
        if (console && console.log) {
            console.log(result);
        }

        sforce.console.openSubtab(primaryTabId , 'https://na1.salesforce.com/apex/service_cloud_console_flow_1', true, 
            'Add New Service',null,openSuccess);
    }
    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>
<button type="button" onclick="testOpenSubtab();">Test Subtab</button>

Additionally there are two other ways to change tabs in VF with the srcUp and srcSelf functions. srcUp is used to open a subtab and srcSelf is used to change the current tabs location. These two methods are very useful for javascript custom buttons as well.

You can find a lengthy example from one of the PMs of service cloud console Gautam Vasudev in his descriptive post, on the idea exchange for some reason...

https://success.salesforce.com/ideaView?id=08730000000YKxYAAW

Because the srcUp function is only available in the context of console you'll want to check for whether the function exists to determine if you're in that context, otherwise handle appropriately for your VF being hosted externally (call window.open for example).

Here is a brief example:

var url = 'http://someurl.com'; // or {!$Page.somevf}, or urlfor($action.... etc
if (typeof(srcUp) == 'function') {
    srcUp(url);
} else {    
    window.open(url); // open new browser tab if not in console context
}
0

enter image description hereYou can try Custom console Components and you can add the URls there.

Setup ->Customise -> Console -> Custom Console Components

Add them to the Page Layout it is displayed at the top as a button . From here you can configure you UI to have sidebars where you can display the URLS.

0

source

<apex:includeScript value="/support/console/20.0/integration.js"/>
    <script type="text/javascript">
        function testSetTabTitle() {
            //Set the current tab's title
            sforce.console.setTabTitle('Lead: {!Lead.Name}');
        }
        var pageLoad = window.onload;
          window.onload = function() {
                if (pageLoad) {
                        pageLoad();
                }
                  testSetTabTitle();
          }
    </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.