[英]Get data from parent form in a popup CRM Dynamics 2015
I have a button on an entity form which opens a CRM modal. 我在实体表单上有一个按钮,用于打开CRM模式。 I need to get to form data from the IFrame inside that modal, I tried a lot of ways. 我需要从该模式下的IFrame生成数据,我尝试了很多方法。 I included ClientGlobalContext.js.aspx reference in the IFrame html, I also tried with 我在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? 还有其他选择吗?
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!)? 这是在页面或类似window.showModalDialog(已弃用!)之类的页面中插入框架的jQuery-UI样式模式吗?
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. 为简便起见,我排除了在窗体卸载时清理函数,确保在调用之前定义了函数等问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.