2

In the service console, when an agent receives a chat request, case is opened and chat display on the left panel(picture attached below). I want to close the case subtab, that is under chat primarytab, upon click of a custom javascript button.

enter image description here

Javascript button code

{!REQUIRESCRIPT("/support/console/36.0/integration.js")}
if (sforce.console.isInConsole()) {
    alert("IS in console");
    sforce.console.getEnclosingTabId(closeSubtab);
} 

var closeSubtab = function closeSubtab(result) {
    //Now that we have the tab ID, we can close it
    alert("closing subtab...");
    var tabId = result.id;
    sforce.console.closeTab(tabId);
};

Problem

Now, first alert is showing, but the second is not and hence, the subtab doesn't close. Am I missing something?

1 Answer 1

1

I think it could the issue of API which you are using. Following code perfectly works for me

{!REQUIRESCRIPT("/support/console/36.0/integration.js")}

 var callback = function () {
     if (result.error) {
        alert("Error message is " + result.error);
     }
 };
function testCloseTab() {
    //First find the ID of the current tab to close it
    sforce.console.getEnclosingTabId(closeSubtab);

 }

var closeSubtab = function closeSubtab(result) {

    //Now that we have the tab ID, we can close it
    var tabId = result.id;
    sforce.console.closeTab(tabId, callback);
};

testCloseTab();

For more information, refer closeTab()

1
  • It just did. I wonder what went wrong with my code, mind boggling sometimes.
    – Mahmood
    Commented Jul 5, 2017 at 18:41

You must log in to answer this question.

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