0

The JS below runs accordingly, but it never hits the last function (showAllTabIdRedirect). Any idea why? Is it my syntax? I am trying to run the first function that grabs the primary tab id and then use that to pass along some other functions. In the end, I would redirect the user as well as refresh a specific tab.

    <script>
        
         function refreshDetailsTab() {
            sforce.console.getEnclosingPrimaryTabId(focusDetailSubtabRedirect);
            
            var formsId;
            
            var currentUrl = window.location.href;

            if (currentUrl) {
                formsId = currentUrl.split('?formId=')[1];
            } else {
                return;
            }
            
            window.location = '/' + formsId;
            debugger;
                         
         };
         
         sforce.console.getEnclosingPrimaryTabId(focusDetailSubtabRedirect);
         
        var focusDetailSubtabRedirect = function showTabIdRedirect(result) {
            // window.onload = function showTabIdV1(result) {
            //alert('2222');
            var primaryTabID = result.id;
            
            sforce.console.getSubtabIds(primaryTabID , showAllTabIdRedirect);
            debugger;
        }

         var showAllTabIdRedirect = function showAllTabIdRedirect(result2) {
            // alert('33333');
            var firstSubTab  = result2.ids[0];
            
            sforce.console.refreshSubtabById(firstSubTab, false);
            debugger;
            //alert('Subtab IDs=====: ' + result.ids[0]);
        }; 
                    
    window.onload = refreshDetailsTab;
    
    </script>  
  • is the function showTabIdRedirect being executed? – Y.L Jul 20 '17 at 04:11
  • where are you passing the 'result' param to 'showTabIdRedirect'? – Kamlesh Arya Jul 20 '17 at 04:26
  • Thanks for the response. It's grabbing the ids because when I removed the code to redirect the user (all the formsId code), the sfdc function works fine. see screenshot: oi68.tinypic.com/htu4c3.jpg – Peter Hoang Jul 20 '17 at 04:28

2 Answers2

0

You can check for successful completion of those methods. It's possible 'getSubtabIds' was at halt for some reason and that would cause the failure of calling the callback function 'showAllTabIdRedirect '.

See the documentation here for getSubtabIds

  • Thanks for the response. It's grabbing the ids because when I removed the code to redirect the user (all the formsId code), the sfdc function works fine. – Peter Hoang Jul 20 '17 at 04:15
0

I think it has something to do with the window.location triggering first. It redirects the user before the other JS can load.