I have the opportunity form script with a function.
On the form I have also embedded an htm resource in an iframe.
From the iframe javascript I want to call a function on the opportunity form script.
How can I achieve that?
I have the opportunity form script with a function.
On the form I have also embedded an htm resource in an iframe.
From the iframe javascript I want to call a function on the opportunity form script.
How can I achieve that?
Based on the example you posted I created my own function that works better (but not 100% perfect yet)
Since I know that I have a namespace with name "releye" in the form script I iterate the frames in window.parent until I find that namespace and then I call this frame. I noticed that sometimes the frame had different indexes and therefore the code needed some adjustments..
getParentFrame().myMethod();
function getParentFrame() {
let frame = null;
for (var i = 0; i < window.parent.frames.length; i++) {
try {
let releye = window.parent.frames && window.parent.frames[i] ? window.parent.frames[i].releye : null;
if (releye && releye != undefined) {
frame = window.parent.frames[i];
break;
}
}
catch(e)
{
if (e.message)
throw e.message;
else
throw e;
}
}
return frame;
}
The article helped me find a solution even though it didn't exactly as proposed there. (sort of)
For me (Unified Interface) the following worked:
OPPORTUNITY FORM
someFunction = function () { // Do stuff }
HTM WEB RESOURCE in Iframe
function someting() { window.parent.frames[0].someFunction(); }
Hi Fedorov,
This article explains how to call JavaScript functions defined in Microsoft Dynamics CRM forms from an IFRAME.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156