getPageInfo() for Salesforce Classic

Usage

Returns information about the current page.

Syntax

sforce.interaction.getPageInfo(callback:function);

Arguments

Name Type Description
callback function JavaScript method executed when the API method call is completed.

Sample Code–JavaScript

<!-- javascript set_clipboard -->
<html>
<head>
   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
   <script type="text/javascript">
       var callback = function (response) {
           if (response.result) {
                  alert(response.result);
            } else {
                   alert(response.error);
           }
        };
       function getPageInfo() {
                //Invokes API method
                sforce.interaction.getPageInfo(callback);
        }
</script>
</head>
<body>
       <button onclick="getPageInfo();">getPageInfo</button>
</body>
</html>

Response

Name Type Description
result string Returns the URL of the current page as a JSON string, including any applicable object ID, object name, object type, and for API version 33.0 or later, the object tab name. For API version 31.0 and later, invoking this method on a PersonAccount object also returns accountId or contactId, and personAccount (true if the object is a PersonAccount, false otherwise).
error string If the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.

Example result:

{"url":"https://MYDOMAINNAME.my.salesforce.com/001x0000003DGQR",
"objectId":"001x0000003DGQR","objectName":"Acme",
"object":"Account","displayName":"Company"}

Example result for a PersonAccount object (API version 31.0 and later):

{"url":"https://MYDOMAINNAME.my.salesforce.com/001x0000003DGQR",
"objectId":"001x0000003DGQR","objectName":"Acme Person Account",
"object":"Account", "contactId":"003D000000QOMqg", "personAccount":true}