You need to sign in to do that
Don't have an account?
Erica Cox
Need to perform action if particular subtab is open
I have the need to disable the buttons on a page if a particular subtab is open in a certain state, as indicated in the URL of the subtab. The code below works sometimes, but only if that tab happens to be last in the list. The return statement here doesn't break the loop, because it just returns from the callback. Tried setting a var in the for loop and doing the disable code after the loop if the var was true, but but that doesn't work because getPageInfo is asynchronous.
var evalSubTabIdsCallback = function (result) { if(result.ids != null) { var arrTabIds = result.ids; var arrLength = arrTabIds.length; for(var i = 0; i <arrLength ; i++) { var tabId = arrTabIds[i]; sforce.console.getPageInfo(tabId,function(pageInfoResult){ var JSONObj = JSON.parse(pageInfoResult.pageInfo); var url=JSONObj["url"]; if( url.indexOf('addingFromCase=true') > 0 ) { buttonsEnabled(false); gIsScreenDisabled = true; return; } else { buttonsEnabled(true); gIsScreenDisabled = false; } }); } } }; var focusedCaseTabListener = function (result) { var primaryTabId = null; sforce.console.getSubtabIds(primaryTabId , valSubTabIdsCallback); };