使用 Javascript 清空 CRM 2013 中电子邮件实体中的发件人字段
Emptying the from field in the email entity in CRM 2013 using Javascript
因此,每当我加载页面时,我都会尝试清空电子邮件实体上的发件人字段。我正在尝试使用 javascript 这样做。我的代码如下。
function emptyField(fieldName) {
var personType = Xrm.Page.getAttribute(fieldName).DataValue = [];
}
我也试过
function emptyField(fieldName) {
var personType = Xrm.Page.getAttribute(fieldName).DataValue = null;
}
None 这些方法似乎有效。谁能告诉我我能做什么?
OOB functionality 是这样的:
function emptyField(fieldName) {
Xrm.Page.getAttribute(fieldName).setValue(null);
}
仔细检查 MSDN 页面中的说明:
Updating an attribute using setValue will not cause the OnChange event handlers to run. If you want the OnChange event handlers to run you must use fireOnChange in addition to setValue.
When Microsoft Dynamics CRM for tablets is not connected to the server setValue will not work.
You cannot set the value of composite attributes. More information: Write scripts for composite attributes.
Alex 的回答有效。但它不会将空值保存到字段中。如果您想保存它,只需添加此代码:
function setValue(toSet) {
Xrm.Page.data.entity.attributes.get('myField').setValue(toSet);
Xrm.Page.getAttribute('myField').setSubmitMode('always');
Xrm.Page.data.entity.save();
}
因此,每当我加载页面时,我都会尝试清空电子邮件实体上的发件人字段。我正在尝试使用 javascript 这样做。我的代码如下。
function emptyField(fieldName) {
var personType = Xrm.Page.getAttribute(fieldName).DataValue = [];
}
我也试过
function emptyField(fieldName) {
var personType = Xrm.Page.getAttribute(fieldName).DataValue = null;
}
None 这些方法似乎有效。谁能告诉我我能做什么?
OOB functionality 是这样的:
function emptyField(fieldName) {
Xrm.Page.getAttribute(fieldName).setValue(null);
}
仔细检查 MSDN 页面中的说明:
Updating an attribute using setValue will not cause the OnChange event handlers to run. If you want the OnChange event handlers to run you must use fireOnChange in addition to setValue.
When Microsoft Dynamics CRM for tablets is not connected to the server setValue will not work.
You cannot set the value of composite attributes. More information: Write scripts for composite attributes.
Alex 的回答有效。但它不会将空值保存到字段中。如果您想保存它,只需添加此代码:
function setValue(toSet) {
Xrm.Page.data.entity.attributes.get('myField').setValue(toSet);
Xrm.Page.getAttribute('myField').setSubmitMode('always');
Xrm.Page.data.entity.save();
}