This is regarding Click to Dial functionality and Open CTI Connector.

I have a usecase where when the user clicks on phone number, call gets initiated and user will get connected with the number called. Is there any way to have some apex logic executed as soon as the user clicks on phone number and allows to make a call or stop from making call based on the result of logic executed.

Any pointers would be helpful.

  • I have tried to throw some pointers – Santanu Boral Dec 19 '16 at 5:27
  • What am I missing... In the listener if you don't make a call then no call is made. – Grant Schenck Apr 7 '17 at 12:04

You need to use visualforce and controller Extension to meet your requirement.

Use support:clickToDial component which renders a valid phone number as click-to-dial enabled for Open CTI. This field respects any existing click-to-dial commands for computer-telephony integrations (CTI) with Salesforce.

<apex:page standardController="Account" extensions= "ClickToDialController" showHeader="true">

public class ClickToDialController {

   public ClickToDialController(ApexPages.StandardController stdController){}

    public String getParams(){
      //put your logic here

For more information refer support:clickToDial

Otherwise, you have to connect to Open CTI and play around with the methods of interaction.js and use this function.

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

   <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 );
              //put your logic here
   //Invokes API method

Refer onClickToDial() for Salesforce Classic

  • Thanks for reply. I tried this but here I want to add custom logic and also based on logic I want to prevent the call which is being made. In listener I tried returning false but it does not work still call passes through. Any way to prevent for call being made? – Kiran Machhewar Dec 19 '16 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.