Newer Version Available
getEnclosingTabId() for Lightning Experience
Returns the ID of the enclosing tab.
Arguments
None.
LWC Sample Code
To get the ID of the enclosing tab in LWC, use the EnclosingTabId wire adapter.
This component retrieves the enclosing tab ID and closes the tab.
Aura Components Sample Code
This component has a button that, when pressed, retrieves the enclosing tab ID.
Component code:
Controller code:
Response
This method returns a promise that, upon success, resolves
to the tabId of the enclosing tab, if within a tab,
or false if not within a tab.