setVisible() for Salesforce Classic

Usage 

Shows or hides the softphone in the Salesforce console.

If this method is used in a Salesforce console where multi-monitor components is turned on, an error will be returned.

Note

Syntax 

1sforce.interaction.setVisible(value:boolean, (optional) callback:function)

Arguments 

NameTypeDescription
valuebooleanSet value to true to show the softphone or set value to false to hide the softphone.
callbackfunctionJavaScript method executed when the API method call is completed.

Sample Code–JavaScript 

1<html>
2<head>
3   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
4   <script type="text/javascript">
5       var callback = function (response) {
6           if (response.result) {
7              alert(response.result);
8           } else {
9              alert(response.error);
10           }
11        };
12   function setVisible(value) {
13           sforce.interaction.setVisible(value, callback);
14   }
15</script>
16</head>
17<body>
18       <button onclick="setVisible(false);">hide softphone</button>
19</body>
20</html>

Response 

NameTypeDescription
resultbooleantrue if showing or hiding the softphone succeeded, false if showing or hiding the softphone didn’t succeed.
errorstringIf the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.