从弹出式CRM Dynamics 2015中获取父表单中的数据

时间:2022-12-03 15:41:31

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

我在实体表单上有一个按钮,用于打开CRM模式。我需要从该模态中的IFrame中形成数据,我尝试了很多方法。我在IFrame html中包含了ClientGlobalContext.js.aspx引用,我也试过了

$.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?

还有其他选择吗?

1 个解决方案

#1


0  

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!)?

你能说明你的模态是如何创建的吗?这是一个jQuery-UI样式模式,在页面中插入一个框架或类似window.showModalDialog(不建议使用!)?

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:

假设在同一个“顶部”框架中的某个对话框,我就是这样处理的。假设我在帐户记录上有一个表单脚本。在我的onload函数中,我配置了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.

为简洁起见,我在表单卸载时排除了清理函数,确保在调用之前定义了函数等。

#1


0  

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!)?

你能说明你的模态是如何创建的吗?这是一个jQuery-UI样式模式,在页面中插入一个框架或类似window.showModalDialog(不建议使用!)?

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:

假设在同一个“顶部”框架中的某个对话框,我就是这样处理的。假设我在帐户记录上有一个表单脚本。在我的onload函数中,我配置了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.

为简洁起见,我在表单卸载时排除了清理函数,确保在调用之前定义了函数等。