无法确定如何使用新的retrieveMultipleRecords(客户端API参考)从以下fetchXml获取结果:
var request = "<fetch output-format='xml-platform' distinct='true' version='1.0' mapping='logical'>" +
"<entity name='msdyn_incidenttype'>" +
"<attribute name='msdyn_name'/>" +
"<attribute name='createdon'/>" +
"<attribute name='msdyn_estimatedduration'/>" +
"<attribute name='msdyn_incidenttypeid'/>" +
"<order attribute='msdyn_name' descending='false'/>" +
"<link-entity name='product' link-type='inner' alias='ag' from='productid' to='aka_productfamilyid'>" +
"<link-entity name='msdyn_customerasset' link-type='inner' alias='ah' from='msdyn_product' to='productid'>" +
"<filter type='and'>" +
"<condition attribute='msdyn_customerassetid' operator='eq' uiname='' uitype='msdyn_customerasset' value='${custAssetId}'/>" +
"</filter>" +
"</link-entity>" +
"</link-entity>" +
"</entity>" +
"</fetch>";
我将上述fetchXml与新的客户端api参考结合使用,如下所示:
var results = Xrm.WebApi.retrieveMultipleRecords("msdyn_incidenttype",request).then(
function success(result) {
for (var i = 0; i < result.entities.length; i++) {
console.log(result.entities[i]);
}
console.log("Next page link: " + result.nextLink);
// perform additional operations on retrieved records
},
function (error) {
console.log(error.message);
// handle error conditions
}
我阅读的文档(https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/retrievemultiplerecords)指出第二个参数是选项,如果是fetchXml(如我所用),则在此处指定它。但是我在控制台中收到以下错误:
HTTP400:错误的请求-请求无法由请求处理 服务器由于语法无效。 (XHR)获取- https://dev.crm.dynamics.com/api/data/v9.0/msdyn_incidenttypes?fetch output-format ='xml-platform'distinct ='true'version ='1.0' mapping ='逻辑'>实体名称='msdyn_incidenttype'>属性 name ='msdyn_name'/>属性name ='createdon'/>属性 name ='msdyn_estimatedduration'/>属性 name ='msdyn_incidenttypeid'/>订单属性='msdyn_name' 降序=“ false” />链接实体名称=“产品” link-type =“内部” alias ='ag'从='productid'到='aka_productfamilyid'>链接实体 name ='msdyn_customerasset'link-type ='inner'alias ='ah' 从='msdyn_product'到='productid'>过滤器类型='and'>条件 attribute ='msdyn_customerassetid'运算符='eq'uiname ='' uitype ='msdyn_customerasset' value ='$ {custAssetId}'/> / filter> / link-entity> / link-entity> / entity> / fetch>
我在这里想念东西吗?
答案 0 :(得分:1)
您应该像下面这样在前面添加"?fetchXml="
:
Xrm.WebApi.retrieveMultipleRecords("msdyn_incidenttype", "?fetchXml= " + request).then(
function success(result) {
return result;
},
function (error) {
console.log("failed with error: ", error);
return null;
}
);
选项
OData系统查询选项或FetchXML查询来检索您的数据。
支持以下系统查询选项:$ select,$ top,$ filter,$ expand和$ orderby。
要指定FetchXML查询,请使用
fetchXml
属性指定查询。