onClickToDial() for Lightning Experience

Usage 

Registers a function to call when a user clicks an enabled phone number. This method is available in API version 38.0 or later.

You can use this method with the Lightning web component lightning-click-to-dial. You can also use it with the Aura component lightning:clickToDial. Keep in mind that you can’t use either component in iFrames. This method can’t be used with the Visualforce component support:clickToDial.

Note

Syntax 

1sforce.opencti.onClickToDial({
2     listener: FUNCTION
3})

Arguments 

NameTypeDescription
listenerfunctionJavaScript method called when the user clicks an enabled phone number.

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 listener = function(payload) {
6        console.log('Clicked phone number: ' + payload.number);
7      };
8
9      // Register the listener.
10      window.addEventListener('load', function() {
11        sforce.opencti.onClickToDial({listener: listener});
12      });
13   </script>
14  </head>
15</html>

Payload 

The payload object passed to each call to the listener method contains the following fields.

NameTypeDescription
numbernumberProvides the phone number clicked by the user.
recordIdstringProvides the ID of the record associated with the clicked phone number.
recordNamestringProvides the name of the record for the clicked phone number.
objectTypestringProvides the type of record associated with the clicked phone number.
accountId or contactIdstringIf the clicked phone number belongs to a person account, the associated account or contact ID is provided.
personAccountbooleanIf the clicked phone number belongs to a person account, this property is true.If person accounts aren’t enabled in your org, this field isn’t included in the payload object.
paramsstringComma-separated list of parameters associated with the phone number passed into the component.