Newer Version Available
getTabURL() for Lightning Experience
Returns the URL of the specified tab. This method works only in
Lightning console apps.
Arguments
| Name | Type | Description |
|---|---|---|
| tabId | string | ID of the tab for which to retrieve the URL. |
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: '#/sObject/001R0000003HgssIAC/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})Response
This method returns a promise that, upon success, resolves to the
URL of the specified tab.