Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

openConsoleUrl() for Lightning Experience

Opens a URL generated by generateConsoleUrl(). This method works only in Lightning console apps. This method isn’t supported for Lightning Web Components (LWC).

Arguments

Name Type Description
url string Console URL representing the array of URLs passed into Salesforce.
focus boolean Optional. If true, the workspace tab opens and displays immediately. If false, the workspace tab opens in the background.
labels string[] Optional. An array of labels for the opened tabs. The order that the tabs appear in the URL should match the order in the array. Use an emptry string if you don’t want to set any labels.

Aura Components Sample Code

This component has a button that, when pressed, opens a workspace using the openConsoleUrl()method.

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:workspaceAPI aura:id="workspaceAPI" />
3    <lightning:button label="Open Console URL" onclick="{! c.handleOpenConsoleUrl }" />
4</aura:component>

Controller code:

1// Assume URL generated by generateConsoleUrl() API
2// E.g. /lightning/r/Account/001xx000003DGQYAA4/view?ws=%2Flightning%2Fr%2FAccount%2F001xx000003DGQXAA4%2Fview&ctabs=%2Flightning%2Fr%2FAccount%2F001xx000003DGQWAA4%2Fview&activectab=2
3({
4    handleOpenConsoleUrl : function(component, event, helper) {
5        var url = generateConsoleUrl();
6        var workspaceAPI = cmp.find("workspaceAPI");
7        workspaceAPI.openConsoleURL({
8            "url": url,
9            "focus": true,
10            "labels": ["Workspace Label", "First Subtab Label", "Second Subtab Label"]
11        }).then(function(activeTabId) {
12        console.log(activeTabId);
13    })
14        .catch(function(error) {
15            console.log(error);
16        })
17    }
18});

Response

This method returns a promise that, upon success, resolves to the tabId of the active tab.