7

Well I am trying to call a number using CTI adapter. But somehow I am unable to make it work. I used the code from Salesforce Doc(http://www.salesforce.com/us/developer/docs/api_console/index.htm)

<apex:page>
    <apex:includeScript value="/support/console/24.0/integration.js"/>
     <script type="text/javascript">

           var callback = function (result) {
              if (result.success) {
                 alert('CTI message was sent successfully!');
             } else {
                 alert('CTI message was not sent successfully.');
               }
           };

          //Note that we are using the CTI submodule here
           sforce.console.cti.sendCTIMessage('/ANSWER?LINE_NUMBER=1', callback);
     </script>
</apex:page>

But I am getting cross domain error

Uncaught SecurityError: Blocked a frame with origin "https://cs10.salesforce.com" from accessing a frame with origin "https://c.cs10.visual.force.com". Protocols, domains, and ports must match.

Any Idea what I am doing wrong here ?

3

Well I guess I found a way out. Instead of using integration.js I used interaction.js which is generally used to communicate with CTI and directly called the method by just "sendCTIMessage"

<apex:page>
    <script src="/support/api/26.0/interaction.js" type="text/javascript"></script>
     <script type="text/javascript">

           var callback = function (result) {
              if (result.success) {
                 alert('CTI message was sent successfully!');
             } else {
                 alert('CTI message was not sent successfully.');
               }
           };

          //Note that we are using the CTI submodule here
           sendCTIMessage('/ANSWER?LINE_NUMBER=1', callback);
     </script>
</apex:page>

This code seems to work perfectly.

Few observations

  • To make this work the user must have Call center associated.
  • Once Call center is associated "sendCTIMessage" method gets available."sendCTIMessage" this method doesnt seem to be documented but it does works(please note it doesnt have a namespace like sforce.cti.XXX)
2

Here Parent page is from Salesforce domain and the Visualforce page you wrote is from force.com domain.

sendCTIMessage is sending message through different domain so that communication cannot be happened.

To make it work both Console and Visualforce page must be from same domain at least.

One of the work around can be is create custom interaction log which will allow complete control over the Console and CTI Softphone. It is possible to create custom interaction log after spring '12.

In addition, No browser allow cross-domain referencing. Therefore, you are getting this error. It is a browser security feature.

More details about it is in this question asked earlier: iframe: Protocols, domains, and ports must match error . Also you can workaround this by changing the approach to PostMessaging.

  • well the example that I quoted is from the Salesforce Docs. And even I checked the integration.js they have cross domain communication implementation using PostMessaging/HTML5 . – Avidev9 Oct 20 '13 at 9:06
  • Try with /support/console/29.0/integration.js – Ashwani Oct 22 '13 at 8:46

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.