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.
generateConsoleUrl()
Generates a URL to a tab, or group of related tabs,
in the Salesforce console. If any tabs include external URLs, then add the external URLs
to the console’s allowlist so that they can display correctly.This method is only
available in API version 28.0 or later.
Syntax
1sforce.console.generateConsoleUrl(urls:String, (optional)callback:Function)Arguments
| Name | Type | Description |
|---|---|---|
| urls | string | An array of URLs. The first URL is a primary tab and subsequent URLs are subtabs. Note that the last URL is the subtab on which the console is focused. These URLs can be standard Salesforce URLs or relative URLs. |
| callback | function | JavaScript 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 generate a console URL</A>
5
6 <script type="text/javascript">
7 function showConsoleUrl(result) {
8 alert(result.consoleUrl);
9 }
10 function testGenerateConsoleURL() {
11 sforce.console.generateConsoleUrl([/apex/pagename, /entityId, www.externalUrl.com, Standard Salesforce Url/entityId], showConsoleUrl); }
12 </script>
13</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:
| Name | Type | Description |
|---|---|---|
| consoleUrl | string | Console URL that represents the array of URLs passed into Salesforce. |
| success | boolean | true if the URL was generated successfully, false if otherwise. |
| callback | function | JavaScript method that’s called upon completion of the method. |