Newer Version Available

This content describes an older version of this product. View Latest

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.

To use LWC Workspace API (Beta), Lightning Web Security must be enabled in the Salesforce org. LWC Workspace API is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

Note

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.