Newer Version Available

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

Lightning Console JavaScript API Syntax

Use Lightning Console JavaScript API methods in the JavaScript controller of a Lightning component.

To use the Lightning Console JavaScript API, include lightning:navigationItemAPI, lightning:workspaceAPI, or lightning:utilityBarAPI in your Lightning component.

The lightning:navigationItemAPI, lightning:workspaceAPI, andlightning:utilityBarAPI components give you access to their coordinating APIs. Give each component an aura:id so that you can reference it from the component’s controller.

The follow example shows a simple Lightning component that uses the API libraries:

This component implements flexipage:availableForAllPageTypes so that it can be accessed in the Lightning App Builder.

This is the component’s JavaScript controller:

The controller has three functions, each of which uses an API method. To use a method in a controller, use component.find with the aura:id you gave to the lightning:navigationItemAPI, lightning:workspaceAPI, or lightning:utilityBarAPI.

Methods in the Workspace API and the Utility Bar API take a JSON object as an argument. The values included in the object depend on the method. openTab, for example, takes an object that includes the url and focus (whether the new tab has focus). Check the reference section of this guide before using a method so that you know which arguments to pass to it.