【发布时间】:2018-05-09 17:12:07
【问题描述】:
我希望获得一些关于如何在 Dynamics CRM 365(本地)可编辑网格中执行 setValue 的指示:
无论我尝试什么,我都无法更新网格中的值。此代码获取属性的引用,但 setValue 似乎对网格没有影响。
function updateDocsOK(ctlName, grdName, attributeName) {
var selectedRow = null;
var attributeColl = null;
var twoOptionValue = 0;
try {
//This is the Yes/No value in the dropdown
var ctlValue = Xrm.Page.getAttribute(ctlName).getValue();
if (ctlValue) {
twoOptionValue = 1;
}
//get the selected rows - use the getControl method and pass the grid name.
selectedRow = Xrm.Page.getControl(grdName).getGrid().getRows();
//loop through rows and get the attribute collection
selectedRow.forEach(function (row, rowIndex) {
var att = row.getData().getEntity().attributes.getByName(attributeName);
//This setValue does not work on a two-option
if (att) {
console.log(att.getValue());
att.setValue(twoOptionValue);
console.log(att.getValue());
}
//This setValue does not work on a text field
att = row.getData().getEntity().attributes.getByName("new_testtext");
if (att) {
att.setValue("hello");
}
});
} catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}
【问题讨论】:
标签: javascript dynamics-crm dynamics-crm-365