Получите результаты из fetchXml, используя new retrieveMultipleRecords (ссылка на API клиента) - PullRequest
0 голосов
/ 26 декабря 2018

Не удается понять, как получить результаты из следующего fetchXml, используя новый retrieveMultipleRecords (ссылка на API клиента):

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: BAD REQUEST - Сервер не смог обработать запрос из-за неверного синтаксиса. (XHR) GET - https://dev.crm.dynamics.com/api/data/v9.0/msdyn_incidenttypes?fetch output-format = 'xml-platform' Different = 'true 'версия =' 1.0 'mapping =' логическое '> имя сущности =' msdyn_incidenttype '> имя атрибута =' msdyn_name '/> имя атрибута =' creationon '/> имя атрибута =' msdyn_estimatedduration '/> имя атрибута =' msdyn_incidenttypeid '/> атрибут атрибута = 'msdyn_name' по убыванию = 'false' /> имя объекта ссылки = 'product' link-type = 'inner' alias = 'ag' from = 'productid' to = 'aka_productfamilyid'> имя объекта link= 'msdyn_customerasset 'link-type =' inner 'alias =' ah 'from =' msdyn_product 'to =' productid '> тип фильтра =' и '> атрибут условия =' msdyn_customerassetid 'operator =' eq 'uiname =' 'uitype ='msdyn_customerasset 'value =' $ {custAssetId} '/> / filter> / link-entity> / link-entity> / entity> / fetch>

Я что-то здесь упустил?

1 Ответ

0 голосов
/ 26 декабря 2018

Вы должны добавить "?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 или запрос FetchXML для получения ваших данных.

  • Поддерживаются следующие параметры системных запросов: $ select, $ top, $ filter, $ expand и $ orderby.

  • Чтобы указать запрос FetchXMLиспользуйте атрибут fetchXml для указания запроса.

Ссылка

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...