Newer Version Available
openConsoleUrl() for Lightning Experience
Opens a URL generated by generateConsoleUrl().
This method works only in
Lightning console apps.
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. |
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.openConsoleUrl }" />
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
3var url = generateConsoleUrl();
4var workspaceAPI = cmp.find("workspaceAPI");
5workspaceAPI.openConsoleURL({
6 "url": url,
7 "focus": true,
8 "labels": ["Workspace Label", "First Subtab Label", "Second Subtab Label"]
9}).then(function(activeTabId) {
10 console.log(activeTabId);
11})
12.catch(function(error) {
13 console.log(error);
14});Response
This method returns a promise that, upon success, resolves to the tabId of the active tab..