Newer Version Available
getFocusedPrimaryTabObjectId()
Returns the object ID of the primary tab on
which the browser is focused. This method is only available in API version 25.0 or
later.
Syntax
1sforce.console.getFocusedPrimaryTabObjectId((optional) callback:Function)Arguments
| Name | Type | Description |
|---|---|---|
| callback | function | JavaScript method that’s called upon completion of the method. |
Sample Code–Visualforce
1<apex:page>
2
3 <A HREF="#" onClick="testGetFocusedPrimaryTabObjectId();return false">
4 Click here to get the focused primary tab object ID</A>
5
6 <apex:includeScript value="/support/console/49.0/integration.js"/>
7 <script type="text/javascript">
8 function testGetFocusedPrimaryTabObjectId() {
9 sforce.console.getFocusedPrimaryTabObjectId(showObjectId);
10 }
11 var showObjectId = function showObjectId(result) {
12 //Display the object ID
13 alert('Object ID: ' + result.id);
14 };
15
16 </script>
17
18</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 field:
| Name | Type | Description |
|---|---|---|
| id | string | The object ID of the primary tab on which the browser is focused. If there is no primary tab open, the ID is null. |
| success | boolean | true if returning the primary tab object ID on which the browser is focused was successful; false if returning the primary tab object ID on which the browser is focused wasn't successful. |