0

I have a primary tab that has a subtab in it. I want to remove that subtab and open a new subtab. The new subtab is an account page. I am able to get into both openSubtab and closeTab methods. The closeTab() method is working but the openSubtab is not firing off the page open. I put an alert on it to make sure that it was firing at all and it is being called. I am not entirely sure what is happening. My thoughts are it is order of execution or my url param is not written correctly because it is in console. When I console.log my url param I get: /apex/001g000001jDRCiCAO. Does anyone have any ideas?

            if(sforce.console.isInConsole()){
            sforce.console.openPrimaryTab(null, conversationSessionPrefix, true, '{!HTMLENCODE($Label.livetext__txt_conversation)}'); 

            var closeSubtab = function closeSubtab(result) {
                var tabId = result.id;
                sforce.console.closeTab(tabId);
            };
            sforce.console.getEnclosingTabId(closeSubtab);

           var openSubtab = function openSubtab(result) {
                var tabId = result.id;
                sforce.console.openSubtab(tabId , '/apex/' + accountId, true);
            };
            sforce.console.getPrimaryTabIds(openSubtab);
       }

UPDATE: After combing through the console responses it is telling me that my ID for the subtab is invalid. I will report back when I figure out why it is invalid!

More Updates: "openSubTab: Opening a duplicate tab is not allowed."

1

To view a record in Salesforce, it is simply "/recordId".

sforce.console.openSubtab(tabId , '/'+accountId, true);
0

My Id was being pass incorrectly. I was getting: invalid id: scc-pt-1 for openSubtab(). This post was super helpful.

Salesforce - Console Integration Toolkit : openSubTab: Invalid ID: scc-st-0

I used getEnclosingPrimaryTabId(); rather then getEnclosingTabId() for the openSubtab function. It works but it isn't very UX friendly. There is a big delay between closing the tab and opening a new tab. I might try and figure out a workaround.

           var closeSubtab = function closeSubtab(result) { 
                var tabId = result.id;                  
                sforce.console.closeTab(tabId, gotintoclosetab());
            };
            sforce.console.getEnclosingTabId(closeSubtab);

           var openSubtab = function openSubtab(result) { 
                var tabId2 = result.id;
                console.log('tabid2' + tabId2);
                sforce.console.openSubtab(tabId2, '/' + accountId, true, '' , '', gotintoopentab());
            };
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
0

You can try this approach, let me know if that works

Here sforce.console.refreshPrimaryTabById(primaryTabId, true, refreshSuccess);

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

var openSubtabCreateContact = function openSubtabCreateContact(result) {
    //Now that we have the primary tab ID, we can open a new subtab in it
    var primaryTabId = result.id;

    sforce.console.refreshPrimaryTabById(primaryTabId, true, refreshSuccess);

    sforce.console.openSubtab(primaryTabId , '/' + contactId ,true, 
        'Create Contact', null, openSuccess, 'salesforceSubtab');
};

var openSuccess = function openSuccess(result) {
    //Report whether we succeeded in opening the subtab
    if (result.success == true) {       
    } else {        
    }
};
var refreshSuccess = function refreshSuccess(result) {
    //Report whether refreshing the primary tab was successful
    if (result.success == true) {       
    } else {        
    }
};

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.