onClickToDial() for Salesforce Classic

Usage 

Registers a function to call when a user clicks an enabled phone number.

Syntax 

1sforce.interaction.cti.onClickToDial( listener:function )

Arguments 

NameTypeDescription
listenerfunctionJavaScript method called when the user clicks a phone number.

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 listener = function (response) {
6           if (response.result) {
7              alert('User clicked on a phone number.' + response.result );
8           }
9        };
10   //Invokes API method
11   sforce.interaction.cti.onClickToDial(listener);
12</script>
13</head>
14</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
resultstringReturns the phone number, object ID, object name, and for API version 33.0 or later, the object tab name from where the click was initiated, as a JSON string. For API version 33.0 or later, invoking this method on a PersonAccount object also returns accountId or contactId, and personAccount (true if the object is a PersonAccount, false otherwise).
errorstringIf the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.

Example result:

1{"number":"4155551212","objectId":"001x0000003DIGj","objectName":"Account",
2"displayName":"Company"}

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

1{"number":"4155551212","object Id":"001D000000JWVvP","objectName":"Howard Jones","object":"Account",
2"personAccount":true,"contactId":" 003D000000QOBPX"}