当我打开表单创建新联系人时,我在动态365 for outlook中出现此错误:
生成此错误的代码如下:
var ctxt = Xrm.Page.context;
var IDUser = ctxt.getUserId().replace("{", "").replace("}", "");
var req = new XMLHttpRequest();
req.open("GET", ctxt.getClientUrl() + "/api/data/v8.1/systemusers(" + IDUser + ")?$select=domainname,_businessunitid_value", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function () {
if (this.readyState == 4 ) {
if (this.status == 200) {
var User = JSON.parse(this.responseText);
}
}
};
req.send();
此代码在表单的onload中调用,并且在Web表单中运行良好。
你知道我该如何解决这个问题吗?