Quantcast
Viewing latest article 2
Browse Latest Browse All 41

Failed to initialize Open CTI on page load

I'm getting the following errors when trying to access Open CTI on a visualforce page that has a lightning component embedded in the page. From the browser dev console, I'm getting the following errors:

Uncaught Failed to initialize Open CTI. Ensure that it is loaded from the right frame with the correct URL parameters

The target origin provided does not match the recipient windows origin

<apex:page controller="CC_IncomingPhoneController">   <apex:includeLightning /><apex:includeScript value="/support/console/43.0/integration.js"/><apex:includeScript value="/support/api/48.0/lightning/opencti_min.js" />  <div id="lightning" /><script>    var callback = function(response) {        if (response.success) {            alert(response.returnValue);        } else {            console.error(response.errors);            alert('Something went wrong. Please check error information in developer console.'            );        }    };           function getSoftphoneLayout() {        sforce.opencti.getSoftphoneLayout({            callback: callback        });    }    window.onload=getSoftphoneLayout;            $Lightning.use("c:CC_IncomingPhoneApp", function() {      $Lightning.createComponent("c:CC_IncomingPhone",      { label : "" },"lightning",      function(cmp) {        $A.eventService.addHandler({ "event": "c:CaseNavigate", "handler" : doCaseNav});      });    });</script>   <script>    var doCaseNav = function(event){        var caseId = event.getParam("caseId");        var closeCurrent = event.getParam("closeCurrent");                  sforce.console.openPrimaryTab(undefined, '#/sObject/'+ caseId +'/view', true, 'Phone Case');        if(closeCurrent){            sforce.console.getEnclosingTabId(callCloseTab);        }               };       var callCloseTab= function callCloseTab(result) {        sforce.console.closeTab(result.id);    }</script>    

I found a similar issue that identified the solution here: Uncaught Failed to initialize Open CTI

What I'm trying to do is get the "ANI" and "DNIS" values from the URI and pass them into the lightning component and set the values into attributes in the component that can be prepopulated into a text field in the component. Basically, grab the phone number of the person calling and set that phone number value into the text field. I can see the values do get passed, but I haven't been able to access them. Based on the documentation the getSoftphoneLayout() method returns these values in the response. I was using the syntax from the example in the documentation just to see if I see the values. Thanks.


Viewing latest article 2
Browse Latest Browse All 41

Trending Articles