openConsoleUrl()

Opens a URL created by the generateConsoleUrl() method (a URL to a tab, or group of related tabs, in the Salesforce console). This method is only available in API version 28.0 or later.

Syntax 

1sforce.console.openConsoleUrl(id:String, consoleUrl:URL, active:Boolean, (optional)tabLabels:String, (optional)tabNames:String, (optional)callback:Function)

Arguments 

NameTypeDescription
idstringID of the console tab to override. If the ID corresponds to an existing primary tab, then the existing primary tab is redirected to the given URL because the console prevents duplicate tabs. Use null to create a new primary tab.
consoleUrlstringConsole URL that represents the array of URLs passed into Salesforce.
activebooleanIf true, the opened primary tab displays immediately. If false, the opened primary tab displays in the background and the current tab maintains focus.
tabLabelsstringOptional array of labels of the opened primary tab or subtabs.  The order in which the tabs appear in the console URL should match the order of the labels that appear in the array. If you do not want to set the labels of tabs, use an empty string ('').
tabNamesstringOptional array of names of the opened primary and subtabs.  The order in which the tabs appear in the console URL should match the order of the names that appear in the array. If you do not want to set the names of tabs, use an empty string ('').
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="testGenerateConsoleURL();return false">
4        Click here to open a console URL</A> 
5
6    <script type="text/javascript">
7        var generateConsoleUrl = function testGenerateConsoleURL() {
8            sforce.console.generateConsoleUrl([/apex/pagename, /entityId, www.externalUrl.com, Standard Salesforce Url/entityId], showConsoleUrl);
9         }
10        var openConsoleUrl = function showConsoleUrl(result) {
11            sforce.console.openConsoleUrl(null, result.consoleUrl, true, ['Apex', '', 'Salesforce', ''], ['', '', 'externalUrl', ''])
12         }
13  </script>
14</apex:page>

This example shows that if you want to set a label or name, you must set the other values to empty string (‘’).

Note

Response 

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

NameTypeDescription
successbooleantrue if the console URL was opened successfully, false otherwise.