Customize Console Apps with the Lightning Console JavaScript API

The Lightning Console JavaScript API incorporates new strategies that let you redo a Lightning console application and bar programmatically. These changes apply only to Lightning Experience which available in following editions.

The Lightning Console JavaScript API incorporates new strategies that let you redo a Lightning console application and bar programmatically. These changes apply only to Lightning Experience which available in following editions.

  1. Professional
  2. Enterprise
  3. Performance
  4. Unlimited
  5. Developer Edition.

Since the new Lightning Console JavaScript API was introduced to customize console apps in the Winter 18‘release with GA, this Lightning Console JavaScript API brings the advantages of the Console Integration Toolkit to Lightning Experience. The API coordinates with Lightning components utilized as a part of Lightning console applications and the utility bar.

For instance, this component and controller of a Lightning component utilize the openTab() method in the Workspace API. It has a button that, when clicked, opens another workspace tab containing the predefined record. The component then focuses the new tab utilizing the tabId returned by the method.

Component code 

<aura:component implements=”flexipage:availableForAllPageTypes” access=”global” >

<lightning:workspaceAPI aura:id=”workspace” />

<lightning:button label=”Open Tab” onclick=”{! c.openTab }” />

</aura:component>

Controller code 

({

openTab : function(component, event, helper) {

var workspaceAPI = component.find(“workspace”);

workspace.openTab({

url: â€˜#/sObject/001R0000003HgssIAC/view’,

focus: true

}).then(function(newTabId) {

workspaceAPI.focusTab({

tabId: newTabId

});

});

}

})

The following methods are new in API version 41.0. 

Workspace API 

getEnclosingTabInfo() 

Returns information about the focused workspace tab or sub tab.

openTab() for Lightning Experience 

Opens another workspace tab that shows the content of a predefined URL, which can be relative or absolute. If the specified tab is already open, it is focused. This method works only in Lightning console apps.setTabHighlighted()

openSubtab() for Lightning Experience 

Opens a subtab inside a workspace tab. The new subtab shows the content of the predetermined URL. If a tab with that URL already exists and focus is set to true, it is focused. This method works only in Lightning console applications.

getEnclosingTabId() for Lightning Experience 

Returns the ID of the enclosing tab. This method works only in Lightning console apps.

closeTab() for Lightning Experience 

Closes a workspace tab or subtab. This method works only in Lightning console apps.

Utility Bar API 

getEnclosingUtilityId() 

Returns the ID of the enclosing utility, or false if not within a utility.

openUtility() for Lightning Experience 

Opens a utility. If the utility is already open, this method has no effect. Only one utility can be open at a time. If another utility is already open, it is limited.

toggleModalMode() 

Toggles modal mode for a utility. While in modal mode, an overlay blocks user from using the console while the utility panel is visible.

setUtilityLabel() for Lightning Experience 

Sets the label of a utility. This text is shown in the utility bar.

Note:   

The API syntax has changed since the pilot version. Methods now use promises instead of callbacks to return responses. Likewise, methods in the Utility Bar API, like methods in the Workspace API, take a JSON array of arguments.

The Lightning components related with the API have also changed. To utilize the Workspace API or the Utility Bar API, include <lightning:workspaceAPI/> and <lightning:utilityBarAPI/>, individually, to your Lightning component.

Console tab events, like lightning:tabClosed and lightning:tabFocused, now utilize the lightning namespace.

The API has a few new strategies and events and a few methods take different arguments. Please refer Salesforce Console Developer Guide reference to see the arguments for a method.

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.