你不见了regardingobjectid
我建议您使用CRM REST Builder,这将帮助您在 CRM 中生成请求、修改和测试。这将显示以红色突出显示的所有必需属性。
var entity = {};
entity.subject = "test";
entity["regardingobjectid_campaign@odata.bind"] = "/campaigns(9CFBD4BD-CD4F-E811-A95A-000D3A1A9407)";
entity.responsecode = 3;
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/campaignresponses", true);
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.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
var uri = this.getResponseHeader("OData-EntityId");
var regExp = /\(([^)]+)\)/;
var matches = regExp.exec(uri);
var newEntityId = matches[1];
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));