在 Dynamics CRM Web API 中使用 savedQuery 时,是否可以应用过滤器?

Is there a way to apply a filter when using a savedQuery in Dynamics CRM Web API?

有没有办法在使用 savedQuery 时应用过滤器? 例如,如果 saved/pre-defined 查看 return 的多个帐户,如以下 URL ".../api/data/v9.0/accounts?savedQuery=9e3ddee9-9e74-e811 -a95d-000d3a34afa9", 有没有办法 return 单个帐户的相同保存视图的结果?

您可以将抓取 XML 发送到 Web API。只需通过高级查找下载视图的 fetch XML。这是 javascript 中的一个例子:

var accountFetchXML = ['< fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' +
            '< entity name="account">' +
            '< attribute name="name" />' +
            '< filter type="and">' +
               '< condition attribute="industrycode" operator="not-null" />' +
            '</ filter>' +
            '< link-entity name="contact" from="contactid" to="primarycontactid" visible="false" link-type="outer" alias="prmContact">' +
               '< attribute name="telephone3" />' +
               '< attribute name="description" />' +
             '</ link-entity>' +
           '</ entity>' +
         '</ fetch>'].join('');

var encodedFetchXML = encodeURIComponent(accountFetchXML);

var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts?fetchXml=" + encodedFetchXML, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange = function () {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 200) {
            var results = JSON.parse(this.response);
            for (var i = 0; i < results.value.length; i++) {
                var accountDetails = results.value[i];

                //Single Line Text
                var nameValue = accountDetails['name'];
            }
        }
        else {
            alert(this.statusText);
        }
    }
};
req.send();