Usage
Returns information about the current application view. This method is available in API version 38.0 or later.
Syntax
sforce.opencti.getAppViewInfo({
callback: FUNCTION
});
Arguments
| Name | Type | Description |
|---|---|---|
callback |
function | JavaScript method executed when the API method call is completed. |
Sample Code–HTML and JavaScript
<!-- html set_clipboard --><html>
<head>
<script type="text/javascript" src="https://domain:port/support/api//lightning/opencti_min.js"></script>
<script type="text/javascript">
var callback = function(response) {
if (response.success) {
console.log('API method call executed successfully! returnValue:', response.returnValue);
} else {
console.error('Something went wrong! Errors:', response.errors);
}
};
function getAppViewInfo() {
sforce.opencti.getAppViewInfo({callback: callback});
}
</script>
</head>
<body>
<button onclick="getAppViewInfo();">getAppViewInfo()</button>
</body>
</html>
Response
This method is asynchronous. The response is returned in an object passed to a callback method.
When you switch from a record detail page to a list view, this method returns:
-
In Lightning Experience, only the
url -
In Lightning Experience console apps, nothing is returned because the listener isn’t invoked
-
success(boolean)- : Returns
trueif the API method call was invoked successfully,falseotherwise.
- : Returns
-
returnValue(object)-
: Returns the URL of the current application view and includes any applicable record ID, record name, and object type. For example:
{ "url": "https://MYDOMAINNAMEmy.salesforce.com/lightning/r/Case/500D0000003tcchIAA/view?t=1459806689555", "recordId": "001x0000003DGQR", "recordName": "Acme", "objectType": "Account" }Invoking this API method on a person account object returns the following additional information.
accountIdorcontactId—The associated account or contact ID.personAccount—Which istrueif person accounts are enabled in your org,falseotherwise.
For example:
{ "url": "https://MYDOMAINNAMEmy.salesforce.com/lightning/r/Account/001x0000003DGQR/view", "recordId": "001x0000003DGQR", "recordName": "Acme Person Account", "objectType": "Account", "contactId": "003D000000QOMqg", "personAccount": true }Since the URL structure of the
returnValuecan change in the future, we recommend that you don’t build any logic based on it.
-
-
error(array)- : If the API call was successful, this variable is
null. If the API call failed, this variable returns an array of error messages.
- : If the API call was successful, this variable is