0

As per workspaceAPI document we don't have any method which checks if any tab/subtab is already opened before opening a new one.

Document for getTabInfo()

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_getTabInfo.htm

JSON Response

{ tabId: string,
     active: boolean,
     pinned: boolean,
     closeable: boolean,
     highlighted: boolean,
     title: string,
     icon: string (SLDS iconKey),
     iconAlt: string,
     recordId: string,
     url: string (URL),
     pageReference: object,
     subtabs: [
         {
             tabId: string,
             active: boolean,
             pinned: boolean,
             closeable: boolean,
             highlighted: boolean,
             title: string,
             icon: string (SLDS iconKey),
             iconAlt: string,
             recordId: string,
             url: string (URL),
             pageReference: object,
             isSubtab: boolean,
             parentTabId: string,
             customTitle: string,
             customIcon: string (URL),
             customIconAlt: string
          },
          { ... }
     ],
     isSubtab: boolean,
     parentTabId: string,
     customTitle: string,
     customIcon: string (URL),
     customIconAlt: string
}

I am using getTabInfo() to fetch all tab details and by using tab title as criteria to check if tab is opened or not.

But I am stuck while iterating through response.response.subtabs is not giving the subtab list I am looking for.

workspaceAPI.getTabInfo({
                tabId: enclosingTabId
            }).then(function(response) {
                var criteria = 'Criteria';
                var subtabList = response.subtabs;
                var subTabInfo = subtabList.find(subTab => criteria === subTab.title); 

Am I missing something?

  • 1
    What does console.log(JSON.stringify(subtabList)) output? – Keith C Jan 12 at 10:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.