1

In the Salesforce Console the URL is always the same and does not contain the Id of the current object

Is there an easy way to get the object Id of the current object while I am on the user interface?

enter image description here

0

You can use Salesforce Console toolkit to achieve what you are looking for. It includes methods to get the object id of the primary tab or subtab. e.g.

getFocusedSubtabObjectId()

Returns the object ID of the subtab on which the browser is focused. For example, a case ID or account ID. This method is only available in API version 24.0 or later.

Reference Code

<apex:page standardController="Case">
    <A HREF="#" onClick="testGetFocusedSubtabObjectId();">
           Click here to get the object ID of the focused subtab</A> 

    <apex:includeScript value="/support/console/24.0/integration.js"/>
    <script type="text/javascript">
        function testGetFocusedSubtabObjectId() {
            sforce.console.getFocusedSubtabObjectId(showObjectId);
        }
            var showObjectId = function showObjectId(result) {
                // Display the object ID
            alert ('Object ID: ' + result.id);
        };
    </script>
</apex:page>

getEnclosingPrimaryTabObjectId()

Returns the object ID of the current primary tab, which contains a subtab. For example, a case ID or account ID. This method works within a primary tab or subtab. This method is only available in API version 24.0 or later.

Reference Code

<apex:page standardController="Case">
    <A HREF="#" onClick="testGetEnclosingPrimaryTabObjectId();">
           Click here to get enclosing primary tab object ID</A> 

    <apex:includeScript value="/support/console/24.0/integration.js"/>
    <script type="text/javascript">
        function testGetEnclosingPrimaryTabObjectId() {
            sforce.console.getEnclosingPrimaryTabObjectId(showObjectId);
        }
            var showObjectId = function showObjectId(result) {
                // Display the object ID
            alert ('Object ID: ' + result.id);
        };
    </script>
</apex:page>
| improve this answer | |
  • I mean how to get the Id of the current object while I am on the user interface, – benahm Mar 2 '17 at 15:34
0

I found a way using the chrome extension Salesforce Inspector

enter image description here

You can inspect and get the Id of the current object in the Salesforce Service Cloud Console

enter image description here

| improve this answer | |
  • Doesn't work for me for console :( – Gunith D Feb 21 '19 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.