Navigation Item API
This component allows you to access methods for programmatically controlling navigation items in Lightning console apps, where navigation items display in an item menu. This component requires API version 43.0 and later.
Descriptor
lightning:navigationItemAPITargets
Lightning Experience
lightning:navigationItemAPI
allows you to access methods for programmatically controlling navigation items in Lightning console apps, where navigation items display in an item menu.
To access the methods, create an instance of the lightning:navigationItemAPI
component and assign an aura:id
attribute to it.
<lightning:navigationItemAPI aura:id="navigationItem"/>
This example creates a button that focuses on the selected navigation object when clicked. If split view is collapsed, the object's list view is opened.
<aura:component implements="flexipage:availableForAllPageTypes" description="My Lightning Component"> <lightning:navigationItemAPI aura:id="navigationItem" /> <div> <lightning:button label="Focus Navigation Item" onclick="{! c.focusNavigationItem }" /> </div> </aura:component>
The button calls the following client-side controller.
{( focusNavigationItem : function(component, event, helper) { var navigationItemAPI = component.find("navigationItem"); navigationItemAPI.focusNavigationItem(); } )}
Usage Considerations
This component provides similar functionality to some of the Salesforce Console Integration Toolkit JS APIs available in Salesforce Classic.
Methods
This component supports the following methods. For more information on these methods, see the Salesforce Console Developer Guide.
focusNavigationItem()
Focuses on the selected navigation object and opens the object's home page. Typically, standard and custom objects open the object's list view. If split view is open, focus remains on the selected navigation object. Returns a Promise. Success resolves to true. The Promise will be rejected on error.
getNavigationItems()
Returns information about all the items in the item menu. Returns a Promise. Success resolves to an array of navigationItemInfo
objects. The Promise will be rejected on error.
getSelectedNavigationItem()
Returns information about the selected navigation item. Returns a Promise. Success resolves to a navigationItemInfo
object. The Promise will be rejected on error.
setSelectedNavigationItem({developerName})
developerName
(string): The ID of the navigation item to select.
Updates the selected navigation item. Returns a Promise. Success resolves to true. The Promise will be rejected on error.
refreshNavigationItem()
Refreshes the selected navigation object's home page. Typically, standard and custom objects open the object's list view. If split view is open, it's refreshed. Returns a Promise. Success resolves to true. The Promise will be rejected on error.