I have a button on an entity form which opens a CRM modal. I need to get to form data from the IFrame inside that modal, I tried a lot of ways. I included ClientGlobalContext.js.aspx reference in the IFrame html, I also tried with
$.each(parent.window.frames, function (i, val) {
if (parent.window.frames[i].Xrm.Page.data.entity != null) {
});
window.parent.Xrm.Page ...
window.top.opener.frames[0].Xrm.Page... //here window top opener is null
window.parent.opener.crmForm.all.name.DataValue //window parent opener is null
Are there any other options?
Can you show how your modal is created? Is this a jQuery-UI style modal that inserts a frame in the page or something like window.showModalDialog (deprecated!)?
Assuming a dialog somewhere in the same 'top' frame, this is how I handle this. Let's say I have a form script on the Account record. In my onload function I configured ISV_Account_Form_onload:
// Return some data from the form
function ISV_GetAccountData(){
return {
Name: Xrm.Page.getAttribute('name').getValue()
};
}
// Runs onload
function ISV_Account_Form_onload{
// Define my function on the top window
top.ISV_GetAccountData = ISV_GetAccountData;
}
Then in my inline-frame I would call:
var accountData = top.ISV_GetAccountData();
This can also work from a pop-up window:
var accountData = top.opener.top.ISV_GetAccountData();
For brevity I've excluded cleaning up the function when the form unloads, making sure the function is defined before calling, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.