dynamics crm 一些常用的js
整理下平時CRM開發中用到的一些基本的js操作
取值:
var oResult = Xrm.Page.getAttribute(sFieldNames).getValue();
var oResult = Xrm.Page.getControl(sFieldNames).getAttribute().getValue();
賦值:
Xrm.Page.getAttribute(sFieldName).setValue(object);
OptionSet: Xrm.Page.getAttribute(sFieldName).setValue(1); //OptionSet的對應選項的Value
Lookup: Xrm.Page.getAttribute(sFieldName).setValue([{ id:"record id", name: "sValue", entityType: "Entity Name" }]);
提示指定錯誤:
Xrm.Page.getControl(sFieldName).setNotification(sErrorMessage);
清除錯誤提示:
Xrm.Page.getControl(sFieldName).clearNotification();
設定Read Only:
Xrm.Page.getControl(sFieldName).setDisabled(true);
設定Enable:
Xrm.Page.getControl(sFieldName).setDisabled(false);
設定必填:
Xrm.Page.getAttribute(sFieldName).setRequiredLevel("required");
設定可選:
Xrm.Page.getAttribute(sFieldName).setRequiredLevel("none");
新增事件:
Xrm.Page.getControl(sFieldName).getAttribute().addOnChange(fnOnChange);