1
我正在嘗試在Dynamics CRM中的窗體上創建一個按鈕,以便onClick按鈕顯示一個對話框。我使用的JS代碼如下:動態CRM自定義窗體事件中的錯誤Javascript
function addButton(attributename) {
if (document.getElementById(attributename) != null) {
var sFieldID = "field" + attributename;
var elementID = document.getElementById(attributename + "_d");
var div = document.createElement("div");
div.style.width = "19%";
div.style.textAlign = "right";
div.style.display = "inline";
elementID.appendChild(div, elementID);
div.innerHTML = '<button id="' + sFieldID + '" type="button" style="margin-left: 4px; width: 100%;" ><img src="/_imgs/ico_16_4210.gif" border="0" alt="Dial this number"/></button>';
document.getElementById(attributename).style.width = "80%";
document.getElementById(sFieldID).onclick = function() {onbuttonclick(); };
}
}
function onbuttonclick() { alert('Hi');}
此功能是用它獲取接觸實體的形式onload事件引發了JS的Web資源。每當表單加載事件觸發時,我在對話框中出現以下錯誤:
此字段的自定義事件發生錯誤。 現場:窗口 事件:onload事件 錯誤:未定義
親切指導我朝決議。 該代碼取自示例示例。
您擁有的示例代碼很糟糕。表單應該通過XRM對象訪問,而不是通過DOM。我建議你看看MSDN上的其他例子。 – Bvrce
你想用這個按鈕做什麼? –
現在我只想運行這個示例,即onClick這個應該顯示一個對話框hi hi – pointer