我被要求为我的组织创建BPF。阅读MSDN,TechNet,dynamics.com e.t.c.我开始工作了。所以我创建了从任务到我的自定义实体的1:N关系。添加查找,映射和BPF。为StageChange添加处理程序以创建自定义实体的新记录。
this.setObjectForTask = function () {
debugger
var context = window.parent.Xrm.Page;
var object = context.getAttribute("kr_object").getValue();
var objectIsEmpty = (object == null || object == "undefined") ? true : false;
if (!objectIsEmpty) {
return;
}
var serverURL = window.parent.Xrm.Page.context.getClientUrl();
var new_object = {};
new_object["new_name"] = "Объект по заявке Ввод информационного листа";
//var client = context.getAttribute("kr_client").getValue();
//new_object["new_customer"] = [{
// id: client[0].id,
// name: client[0].name,
// entityType: client[0].entityType
//}];
var req = new XMLHttpRequest();
req.open("POST", serverURL + "/api/data/v8.1/new_objectses", 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 /* complete */) {
req.onreadystatechange = null;
if (this.status == 204) {
debugger
var new_objectUri = this.getResponseHeader("OData-EntityId");
var ID = new_objectUri.substr(new_objectUri.length - 38).substring(1, 37); //GUID
window.parent.Xrm.Page.getAttribute("kr_object").setValue([{
id: ID,
name: "",
entityType: "new_objects"
}]);
console.log(ID);
} else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send(JSON.stringify(new_object));
};
没有任何反应!即使查找指向自定义实体的新记录,我也无法进入下一阶段。 请解释一下:如何设置此功能以使用乘法实体的记录?! 谢谢。