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

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
    Jul 5 '17 at 18:41

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.