setSoftphonePanelVisibility() for Lightning Experience

Usage 

Sets the visibility status of the softphone panel. When the visible parameter is passed as true, the softphone panel is displayed. When it’s set to false, the panel is minimized. This method is available in API version 38.0 or later.

Syntax 

1sforce.opencti.setSoftphonePanelVisibility({
2   visible:TRUE, 
3   callback:FUNCTION  //Optional
4});

Arguments 

NameTypeDescription
visiblebooleanTo dock (display) the softphone panel, set the value to true. To minimize (hide) the softphone panel, set the value to false.
callbackfunctionJavaScript method executed when the API method call is completed.

Sample Code–HTML and JavaScript 

1<html>
2  <head>
3    <script type="text/javascript" src="https://domain:port/support/api//lightning/opencti_min.js"></script>
4    <script type="text/javascript">
5      var callback = function(response) {
6         if (response.success) {
7            console.log('API method call executed successfully! returnValue:', response.returnValue);
8         } else { 
9            console.error('Something went wrong! Errors:', response.errors);
10         }
11      };
12
13      function setSoftphonePanelVisibility() {
14          sforce.opencti.setSoftphonePanelVisibility({visible: true, callback: callback});
15      }
16     </script>
17  </head>
18  <body>
19    <button onclick="setSoftphonePanelVisibility();">setSoftphonePanelVisibility()</button>
20  </body>
21</html>

Response 

This method is asynchronous. The response is returned in an object passed to a callback method. The response object contains the following fields.

NameTypeDescription
successbooleanReturns true if the API method call was invoked successfully, false otherwise.
returnValueobjectThis API method doesn’t return this object. The returnValue is always null.
errorsarrayIf the API call was successful, this variable is null. If the API call failed, this variable returns an array of error messages.