---
schema_version: "1"
id: de3bc508b0510f491e097021d869d84d1c39e3149819c6251254bf0a2caf0ed9
title: onClickToDial() for Salesforce Classic
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/api-cti/guides/sforce-api-cti-onclicktodial.md
canonical_url: https://developer.salesforce.com/docs/service/api-cti/guide/sforce-api-cti-onclicktodial.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0b8e380b240bff3c37139785b5b5a57577e22a553e97f4d4df57b641d5a9bfd3
products:
  - Open CTI Developer Guide
  - Service Cloud Developer Content
---

# onClickToDial() for Salesforce Classic

## Usage

Registers a function to call when a user clicks an enabled phone number.

## Syntax

```javascript
sforce.interaction.cti.onClickToDial( listener:function )
```

## Arguments

|Name|Type|Description|
|------|------|-------------|
|`listener`|function|JavaScript method called when the user clicks a phone number.|


## Sample Code–JavaScript

<!-- javascript set_clipboard -->
```javascript
<html>
<head>
   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
   <script type="text/javascript">
       var listener = function (response) {
           if (response.result) {
              alert('User clicked on a phone number.' + response.result );
           }
        };
   //Invokes API method
   sforce.interaction.cti.onClickToDial(listener);
</script>
</head>
</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.

|Name|Type|Description|
|------|------|-------------|
|`result`|string|Returns 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).|
|`error`|string|If the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.|


Example `result`:

```javascript
{"number":"4155551212","objectId":"001x0000003DIGj","objectName":"Account",
"displayName":"Company"}
```

Example `result` for a PersonAccount object (API version 33.0 and later):

```javascript
{"number":"4155551212","object Id":"001D000000JWVvP","objectName":"Howard Jones","object":"Account",
"personAccount":true,"contactId":" 003D000000QOBPX"}
```

