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.

getTabURL() for Lightning Experience

Returns the URL of the specified tab. This method works only in Lightning console apps. This method isn’t supported for Lightning Web Components (LWC).

To retrieve the URL of a specified tab in LWC, use getTabInfo().

Arguments

Name Type Description
tabId string ID of the tab for which to retrieve the URL.

Aura Components Sample Code

This component has a button that, when pressed, opens a tab and uses the getTabURL() method to print the new tab’s URL to the developer console.

Component code:

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

Controller code:

1({
2    getOpenedTabURL : function(component, event, helper) {
3        var workspaceAPI = component.find("workspace");
4        workspaceAPI.openTab({
5            url: '/lightning/r/Account/001xx000003DI05AAG/view',
6            focus: true
7        }).then(function(response) {
8            workspaceAPI.getTabURL({
9                tabId: response
10            }).then(function(response) {
11                console.log(response);
12            });
13       })
14        .catch(function(error) {
15            console.log(error);
16        });
17    }
18})

The relative URL used in this example is a placeholder. To try this example yourself, use a relative URL with a record ID from your org.

Note

Response

This method returns a promise that, upon success, resolves to the URL of the specified tab.