getTabLink()

Retrieves the URL to a tab, or group of related tabs, from the Salesforce console. This method is only available in API version 28.0 or later.

Syntax 

1sforce.console.getTabLink(level:String, (optional)tabId:String, (optional)callback:Function)

Arguments 

NameTypeDescription
levelstringLevel that matches one of the Link to Share options in the Salesforce console user interface. The options are:
  • All primary tabs and subtabs — sforce.console.TabLink.PARENT_AND_CHILDREN.
  • Only the specified tab — sforce.console.TabLink.TAB_ONLY
  • A standard Salesforce URL — sforce.console.TabLink.SALESFORCE_URL
tabIdstringOptional tab ID of the tab from which you’re retrieving the URL. If you do not pass a tab ID, the URL to the current tab is returned.
callbackfunctionJavaScript method that’s called upon completion of the method.

Sample Code–Visualforce 

1<apex:page>
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <A HREF="#" onClick="getEnclosingPrimaryTabId();return false">
4        Click here to get tab link</A> 
5
6    <script type="text/javascript">
7        var getEnclosingPrimaryTabId = function getEnclosingPrimaryTabId() {
8            sforce.console.getEnclosingPrimaryTabId(getTabLink);
9        }
10        var getTabLink = function getTabLink(result) {
11            sforce.console.getTabLink(sforce.console.TabLink.PARENT_AND_CHILDREN, result.id, showTabLink);
12        }
13        var showTabLink = function showTabLink(result) {
14            var link = result.tabLink;
15            };
16  </script>
17</apex:page>

Response 

This method is asynchronous so it returns its response in an object in a callback method. The response object contains the following fields:

NameTypeDescription
tabLinkstringThe retrieved URL.
successbooleantrue if the link was retrieved successfully, false if retrieving was unsuccessful.
callbackfunctionJavaScript method that’s called upon completion of the method.