Hi hope you guys are fine.
I have one html web resource and I have JAVASCRIPT in this html web resource plus I have IFrame in this html web resource as well. I have inserted this html web resource on custom entity form using web resource icon menu on main form of entity.
On Page load when i try to access IFrame like this document.getElementById("iframeid") I get IFrame control but when I try to get IFrame using Xrm.Page.ui.controls.get("iframeid") or Xrm.Page.getControl("iframeid") i always get null.
In IFrame I am loading my Canvas app, my canvas app is embeded in model driven app via iframe.
just to let you know , I have html iframe in html web resource like this
<iframe id="myid"></iframe>
I have 3 tabs on form and iframe is on first tab which opens bydefault on page load.
I do not want to use document.getElementById because MS does not recommend it when when try to publish our app to MS app source.
Any idea what i am doing wrong using XRM api ?
nope
just to let you know , I have html iframe in html web resource like this
<iframe id="myid"></iframe>
I can not get form context because it is html web resource. I have tried both but returns null
window.parent.Xrm.Page or parent.Xrm.Page
1. Try either window.parent.Xrm.Page (not recommended) or parent.Xrm.Page (better, but the below may be recommended instead)
2. Use this example of getting form context first using this as a guide:
//Get the value of an option set attribute
var formContext = executionContext.getFormContext();
var value = formContext.getAttribute("new_pagechooser").getValue();
var newTarget = "";
//Set the target based on the value of the option set
switch (value) {
case 100000001:
newTarget = https://myServer/test/pageOne.aspx;
break;
default:
newTarget = https://myServer/test/pageTwo.aspx;
break;
}
//Get the default URL for the IFRAME, which includes the
// query string parameters
var IFrame = formContext.ui.controls.get("IFRAME_test");
var Url = IFrame.getSrc();
// Capture the parameters
var params = Url.substr(Url.indexOf("?"));
//Append the parameters to the new page URL
newTarget = newTarget + params;
// Use the setSrc method so that the IFRAME uses the
// new page with the existing parameters
IFrame.setSrc(newTarget);
use executionContext.getFormContext(); to get the context first for example.
(example from here)
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2