function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marek CechMarek Cech 

Lightning Open CTI screenPop() not working

Hi guys,

I've been trying to use Lightning Open CTI to implement a softphone for Lightning Service Console. Click2dial-related functions work like a charm but screenPop() function keeps throwing this:

This page has an error. You might just need to refresh it. Action failed: c:TestCompo$controller$handleClick [Failed to execute 'postMessage' on 'Window': [object Object] could not be cloned.] Failing descriptor: {c:TestCompo$controller$handleClick}

I've created a Visualforce page and Call Center. The page contains Lightning components. Open CTI is included in page:
​<apex:includeScript value="/support/api/41.0/lightning/opencti_min.js"/>
Even a simple copy pasted code throws the error mentioned above:
sforce.opencti.screenPop({
    type: sforce.opencti.SCREENPOP_TYPE.SOBJECT,
    params: {
        recordId: '0012F0000089wQuQAI'
    }
});
I've double checked that account with hardcoded ID exists in the system.

Any idea how to solve this?
Thanks

 
Ramesh Peetha 4Ramesh Peetha 4
Marek Cech (#), Have you found solution for this, how you included Open CTI in visualforce page, is it through component or directly on the page?
Simon Repar1Simon Repar1
See this answer: https://stackoverflow.com/questions/42376464/uncaught-domexception-failed-to-execute-postmessage-on-window-an-object-co

It works for me. Copy opentcti.js source code to static resource and modify these lines:
original:
parent.postMessage(params, config.sfdcIframeOrigin);

new:
params = JSON.parse(JSON.stringify(params));
parent.postMessage(params, config.sfdcIframeOrigin);
Not perfect solution, but it seems that it is consequence of locker service enforcement which is handling JS objects through native browser Proxy{} object. If you stringify and parse back to JS object it'll remove functions and invalid objects for postmessage and it'll work.

If someone has more advanced answer, please I would like to hear some.
 
salesforcelearner1salesforcelearner1
Hi Simon Repar1,
Can you share me the opentcti.js source code. To make those change as you said above.

Thanks......