我在实体表单上有一个按钮,用于打开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
还有其他选择吗?
答案 0 :(得分:0)
你能说明你的模态是如何创建的吗?这是一个jQuery-UI样式模式,在页面中插入一个框架或类似window.showModalDialog(不推荐使用!)?
假设某个对话位于同一顶部'顶部'框架,这是我如何处理这个。让我们说我在帐户记录上有一个表单脚本。在我的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;
}
然后在我的内联框架中,我会打电话:
var accountData = top.ISV_GetAccountData();
这也可以在弹出窗口中起作用:
var accountData = top.opener.top.ISV_GetAccountData();
为简洁起见,我在表格卸载时排除了清理功能,确保在调用之前定义了该功能等。