gpt4 book ai didi

javascript - 使用新的 retrieveMultipleRecords 从 fetchXml 获取结果(客户端 API 引用)

转载 作者:行者123 更新时间:2023-11-30 19:56:28 24 4
gpt4 key购买 nike

无法确定如何使用新的 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://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-webapi/retrievemultiplerecords ) 指出第二个参数是选项,如果是 fetchXml(如我所用),则在此处指定它。但是我在控制台中收到以下错误:

HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax. (XHR)GET - https://dev.crm.dynamics.com/api/data/v9.0/msdyn_incidenttypes?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=":

Xrm.WebApi.retrieveMultipleRecords("msdyn_incidenttype", "?fetchXml= " + request).then(
function success(result) {
return result;
},
function (error) {
console.log("failed with error: ", error);
return null;
}
);

options
OData system query options or FetchXML query to retrieve your data.

  • Following system query options are supported: $select, $top, $filter, $expand, and $orderby.

  • To specify a FetchXML query, use the fetchXml attribute to specify the query.

Reference

关于javascript - 使用新的 retrieveMultipleRecords 从 fetchXml 获取结果(客户端 API 引用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53935532/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com