2016-06-16 24 views
0

我在打開CRM模式的實體窗體上有一個按鈕。我需要從該模式內的IFrame獲取數據,我嘗試了很多方法。我包括在iframe HTML ClientGlobalContext.js.aspx參考,我也試圖與從彈出式CRM動態2015的父窗體中獲取數據

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

你能展示你的模態是如何創建的嗎?這是一個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(); 

爲了簡潔,我已經排除了在表單卸載時清理函數,確保函數在調用之前被定義等。

相關問題