Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

isSubtab() for Lightning Experience

Checks whether a tab is a subtab. This method works only in Lightning console apps. This method isn’t supported for Lightning Web Components (LWC).

To check whether a tab is a subtab in LWC, use getTabInfo().

Arguments

Name Type Description
tabId string ID of the tab.

Aura Components Sample Code

This component has a button that checks whether the focused tab is a subtab and opens a modal with the answer.

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:workspaceAPI aura:id="workspace" />
3    <lightning:button label="Is the Focused Tab a Subtab?" onclick="{! c.isFocusedTabSubtab }" />
4 </aura:component>

Controller code:

1({
2    isFocusedTabSubtab : function(component, event, helper) {
3        var workspaceAPI = component.find("workspace");
4        workspaceAPI.getFocusedTabInfo().then(function(response) {
5            workspaceAPI.isSubtab({
6                tabId: response.tabId
7            }).then(function(response) {
8                if (response) {
9                    confirm("This tab is a subtab.");
10                }
11                else {
12                    confirm("This tab is not a subtab.");
13                }
14            });
15        })
16        .catch(function(error) {
17            console.log(error);
18        });
19    }
20})

Response

This method returns a promise that, upon success, resolves to true if the tab is a subtab, and false otherwise.