如何使用动态CRM端点从列表中删除联系人

时间:2016-10-07 15:37:13

标签: javascript api dynamics-crm-2011 dynamics-crm crm

我有一个Angular应用程序,它使用内置的DYNAMIC CRM端点,主要是“/XRMServices/2011/OrganizationData.svc”,还有“/api/data/v8.0”用于一些功能,包括调用将成员添加到市场营销列表。

此代码非常适合将成员添加到列表中:

a

但是,当我尝试使用RemoveMemberList调用从列表中删除成员时,它会失败。以下是删除的代码:

function attachContactToList(memberGuid, listGuid) {
    var data = {
        "EntityId": memberGuid
    };
    var req = new XMLHttpRequest();
    req.open("POST", "<<path to CRM Service>>/api/data/v8.0/lists("+ listGuid + ")/Microsoft.Dynamics.CRM.AddMemberList", 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 == 200) {
                notifier.alert("Added to List.");
            } else {
                raiseError(JSON.parse(this.response).error);
            }
        }
    };
    req.send(JSON.stringify(data));
}

我得到的错误是:

function deleteListFromContact(memberGuid, listGuid) {
    var data = {
        "EntityId": memberGuid
    };
    var req = new XMLHttpRequest();
    req.open("POST", "<<path to CRM Service>>/api/data/v8.0/lists(" +  listGuid + ")/Microsoft.Dynamics.CRM.RemoveMemberList", 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 == 200) {
                notifier.alert("Removed from List.");
            } else {
                raiseError(JSON.parse(this.response).error);
            }
        }
    };
    req.send(JSON.stringify(data));
}

任何帮助将不胜感激。这是我整个申请中唯一的绊脚石,一旦纠正了......我很高兴。

由于

1 个答案:

答案 0 :(得分:1)

目前尚未实施删除成员列表请求:

https://msdn.microsoft.com/en-us/library/mt628816.aspx

  

缺少某些组织服务消息的功能和操作   下表列出了没有相应的消息   Microsoft Dynamics CRM Online 2016 Update 1之后的功能或操作   和Microsoft Dynamics CRM 2016 Service Pack 1已应用。

+------------------------------+-----------------------------------+----------------------------------+
| GrantAccessRequest           | GrantAccessRequest                | ModifyAccessRequest              |
+------------------------------+-----------------------------------+----------------------------------+
| QualifyLeadRequest           | ReactivateEntityKeyRequest        | RemoveMemberListRequest          |
+------------------------------+-----------------------------------+----------------------------------+
| RemoveItemCampaignRequest    | RemoveItemCampaignActivityRequest | RetrieveByResourcesServiceReques |
+------------------------------+-----------------------------------+----------------------------------+
| RetrieveFilteredFormsRequest |                                   |                                  |
+------------------------------+-----------------------------------+----------------------------------+

您必须使用“/XRMServices/2011/OrganizationData.svc”或等到下一个版本。