我们正在修复,重新设计旧的 JS Web 资源,以用于最新的 D365 v9 sdk 更改 wrt 客户端脚本 API 改进和弃用。
当使用 重写 web api 方法Xrm.WebApi
时,我们最终得到了这个阻止程序。
场景设置null
为查找,并尝试了以下代码:
var data = {
"abc_relatedentity@odata.bind": null
};
Xrm.WebApi.updateRecord("abc_entity", abc_entityid, data).then(successCallback, errorCallback);
这是抛出错误:
“'odata.bind' 实例或属性注释具有空值。在 OData 中,'odata.bind' 实例或属性注释必须具有非空字符串值。”
这个想法是淘汰下面的冗余 XHR 请求代码。但这是我们现在唯一的解决方法(参考MSDN)。
var req = new XMLHttpRequest();
req.open("DELETE", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.0/accounts(recordGUID)/account_parent_account/$ref", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204 || this.status === 1223) {
//Success - No Return Data - Do Something
}
}
};
req.send();
有人遇到过并处理过吗?我错过了什么吗?