[英]How to update or delete Sender and Receiver of an existing phonecall / email record using MS Dynamics CRM REST Endpoint
我正在开发我需要创建的应用程序,然后使用REST API更新MS Dynamics CRM 2011中的phonecall / email记录。 使用Soap API不是一种选择。
我已经找到了如何创建电话呼叫/电子邮件记录( 这里或这里有详细记录)。
更新现有的电话呼叫/电子邮件记录本身也不是问题。
我的问题是:如何更新现有电话/电子邮件记录的Receiver和Sender字段(To和From)?
到目前为止,我已经尝试了下面描述的不同方法。
我得到Error processing request stream. Deep updates are not supported in PUT operations.
Error processing request stream. Deep updates are not supported in PUT operations.
如果我尝试更新phonecall_activity_parties关系时出错 - 请参阅下面的代码
var callLogEntity = {
"Subject": "My call", "Description": "Call comments go here" };
var activityParties = [];
activityParties.push({
"PartyId": {"Id":"4A9FD17D-5890-4BF0-94AA-D68285C46039", "LogicalName":"contact"},
"ParticipationTypeMask": { "Value": 1 }
}); // sender is a contact
activityParties.push({
"PartyId": { "Id": Xrm.Page.context.getUserId(), "LogicalName": "systemuser" },
"ParticipationTypeMask": { "Value": 2 }
}); // receiver is a current user
callLogEntity.phonecall_activity_parties = activityParties;
var restQueryUrl = "http://<crm_url>/XRMServices/2011/OrganizationData.svc/" +
"PhoneCallSet(guid'" + callLogId + "')";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
data: JSON.stringify(callLogEntity),
url: restQueryUrl,
beforeSend: function (XMLHttpRequest)
{
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "MERGE");
},
success: function (data, textStatus, XmlHttpRequest)
{
console.log("Success");
},
error: function (XmlHttpRequest, textStatus, errorObject)
{
console.warn("Request FAILED: " + XmlHttpRequest.responseText);
}
});
我得到如果我尝试使用此SDK示例中的disassociateRecords方法An activityparty cannot be disassociated from an activity
错误取消关联 - 请参阅下面的代码
var restQueryUrl = "http://<crm_url>/XRMServices/2011/OrganizationData.svc/" +
"PhoneCallSet(guid'" + callLogId + "')/$links/" +
"phonecall_activity_parties(guid'" + activityPartyId + "')";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: restQueryUrl,
beforeSend: function (XMLHttpRequest)
{
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
},
success: function (data, textStatus, XmlHttpRequest)
{
console.log("Success");
},
error: function (XmlHttpRequest, textStatus, errorObject)
{
console.warn("Request FAILED: " + XmlHttpRequest.responseText);
}
});
当我尝试直接从ActivityPartySet删除phonecall_activity_parties中找到的ActivityParty之一时,我收到Forbidden
错误。
var restQueryUrl = "http://<crm_url>/XRMServices/2011/OrganizationData.svc/" +
"ActivityPartySet(guid'" + activityPartyId + "')";
// then do an AJAX POST request with "X-HTTP-Method": "DELETE" header
单独更新该列表中的每个ActivityParty对电话呼叫记录没有影响(即MERGE请求似乎成功,但ActivityParty仍然指向旧记录)
var activityData = {
"PartyId":{"Id":"cc1cdb40-a844-e211-ab1a-000c297d9c06","LogicalName":"contact"},
"ParticipationTypeMask":{"Value":1}
};
var restQueryUrl = "http://<crm_url>/XRMServices/2011/OrganizationData.svc/" +
"ActivityPartySet(guid'" + activityPartyId + "')";
// then do an AJAX post request with "X-HTTP-Method": "MERGE" header
// and activityData as the message body
如果有人能够了解如何更改(或删除,如“清除字段”)发送者和接收者的现有电话/电子邮件记录,我将非常感激。
你能试试这段代码吗? 我希望这会有所帮助。
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "3D417D54-412C-440D-A390-33ED7398254D";
lookupValue[0].name = "UserName";
lookupValue[0].entityType = "systemuser";
lookupValue[1] = new Object();
lookupValue[1].id = "8BD96ECC-573D-E211-A12B-1CC1DE79B4CA";
lookupValue[1].name = "QueueName";
lookupValue[1].entityType = "queue";
createRecord(lookupValue, "EmailSet", _emailCreateSuccess, _error);
//Xrm.Page.getAttribute("to").setValue(lookupValue);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.