Workspace API

The workspace API allows you to perform console-related tasks that include opening tabs and subtabs and to adding focus to opened tabs and subtabs. To use the API, you need to include the Lightning Component Lightning :workspaceAPI in the component. 

The following shows the code snippet on how to use the API:

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <Lightning :workspaceAPI aura:id="workspace"/>
    <Lightning :button label="Close Focused Tab" onclick="{!c.closeFocusedTab}"/>
</aura:component>

The controller code is as follows:

({    closeFocusedTab : function(component, event, helper) {        var workspaceAPI = component.find("workspace"); workspaceAPI.getFocusedTabInfo().then(function(response) { ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.