getSelectedNavigationItem() for Lightning Experience

Returns information about the selected navigation item. This method works only in Lightning console apps.

None

This example identifies the specific navigation menu item currently active in a Lightning console app.

This example checks if a specific object is the current navigation item.

This component has a button that, when pressed, returns information about the selected navigation item.

Component code:

Controller code:

This method returns a promise that, upon success, resolves to a navigationItemInfo object. The promise is rejected on error.

The navigationItemInfo object has the following fields.

NameTypeDescription
labelstringThe navigation item’s label, such as Account or Case.
developerNamestringThe navigation item’s developer name that uniquely identifies the item. For example, Salesforce_Account or Your_VF_Page_Name.
selectedbooleanTrue if the tab is currently selected, false otherwise.
pageReferenceobjectThe representation of the current page. The object returns information such as: page type (for example standard__objectPage or standard__navItemPage), object API name, and state information for the page.

Here’s the structure of a navigationItemInfo object.

The PageReference structure looks like this.