generateConsoleUrl() for Lightning Experience

Generates a URL for a workspace tab and its subtabs. This method works only in Lightning console apps. This method isn’t supported for Lightning Web Components (LWC).

Arguments 

NameTypeDescription
pageReferencespageReference[]An array of page references. The first page reference is the workspace tab. Any following page references are subtabs. The last page reference is the focused subtab.

Sample Code 

This component has a button that, when pressed, uses the generateConsoleUrl() method to create a URL for the provided page references.

Component code:

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

Controller code:

1({
2    handleGenerateConsoleUrl : function(component, event, helper) {
3        var workspaceAPI = cmp.find("workspaceAPI");
4        workspaceAPI.generateConsoleURL({
5            "pageReferences": [
6                {
7                    "type": "standard__recordPage",
8                    "attributes": {
9                        "objectApiName": "Account",
10                        "actionName": "view",
11                        "recordId": "001xx000003DGQXAA4"
12                    },
13                    "state": {}
14                },
15                {
16                    "type": "standard__recordPage",
17                    "attributes": {
18                        "objectApiName": "Account",
19                        "actionName": "view",
20                        "recordId": "001xx000003DGQWAA4"
21                    },
22                    "state": {}
23                },
24                {
25                    "type": "standard__recordPage",
26                    "attributes": {
27                        "objectApiName": "Account",
28                        "actionName": "view",
29                        "recordId": "001xx000003DGQYAA4"
30                    },
31                    "state": {}
32                }
33            ]
34        }).then(function(url) {
35            console.log(url);
36        })
37        .catch(function(error) {
38            console.log(error);
39        });
40    }
41})

Response 

This method returns a promise that, upon success, resolves with the generated URL.

NameTypeDescription
urlstringA console URL that represents the array of URLs passed into Salesforce.