Sort Order parameter for Dynamics 365 API call

Avatar

Avatar

idekaresearch

Avatar

idekaresearch

idekaresearch

18-11-2019

I am using AEM Forms and connecting form elements to Microsoft Dynamics 365.

I use the Form Data Model to create API endpoints to connect with the specific Dynamics 365 entities I am interested in.

The problem I am facing is that the data returned from a Dynamics 365 entity is not in the order I require. The data coming back has a default sort order by created date; I need the data sorted alphabetically to populate a drop-down list.

The APIs in Microsoft Dynamics 365 allow for an Order By parameter; however, I do not know how to specify the Order By parameter in the Form Data Model API. The Form Data Model API allows for a filtering parameter but I cannot seem to get an Order By parameter to work.

Below is some JavaScript used to bind the API endpoint to a drop-down list.

var operationInfo = {

    "formDataModelId": "/content/dam/formsanddocuments-fdm/ms-dynamics-fdm",

    "operationTitle": "GET account /accounts",

    "operationName": "GET account /accounts_15209302043150"

};

var inputs = {

    "isinstitution": true

};

var outputs={

    savedValue:'accountid',

    displayedValue:'name',

    field:this

};

guidelib.dataIntegrationUtils.setOptionsFromService(operationInfo, inputs, outputs);

It doesn't appear that the 'var inputs' allows for an Order By parameter either.

How can I add an Order By parameter to the Microsoft Dynamics 365 API in the Form Data Model or when binding the drop-down list?

Accepted Solutions (0)

Answers (7)

Answers (7)

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

22-11-2019

It might not be documented but we know it exists and work.

Avatar

Avatar

idekaresearch

Avatar

idekaresearch

idekaresearch

20-11-2019

Thanks for the code snippet.

I tried this code already; the callback function was not getting called. It seems like either an unsupported API with a 4th parameter, or has since been deprecated.

The Adobe documentation does not indicate support for a callback function.

I am using AEM v6.4.5

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

20-11-2019

use this rather

guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, callbackFunction);

You can do a set value in the callback funtion.

sample

window.map1 = new Map();

function initializeDropdown(jsonResult) { 

   var arrAllNaics = JSON.parse(jsonResult);

  var arrDropDownItems = [];

  for ( var i=0; i<arrAllNaics.length; i++ )

  { var oNaics = arrAllNaics[i];

   var sDescription = oNaics.agentID;

  

arrDropDownItems.push(sDescription);

map1.set(oNaics.agentID,oNaics.rtastatus);

 

  } dropdownlist1570739946741.items = arrDropDownItems;

 

  }

   var operationInfo = {

"formDataModelId": "/content/dam/formsanddocuments-fdm/fdm2",

"operationTitle": "get",

"operationName": "get_15671949377350"};

   var inputs = { };

   var outputs = { };

guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs, initializeDropdown);

Avatar

Avatar

idekaresearch

Avatar

idekaresearch

idekaresearch

20-11-2019

The returned JSON is abstracted away from me as I am using the Adobe guidelib.dataIntegrationUtils libraries. The returned JSON is not available to use when binding to a drop-down list.

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

18-11-2019

send me sample JSON that you are getting and let me try something.

Avatar

Avatar

idekaresearch

Avatar

idekaresearch

idekaresearch

18-11-2019

Yes, the Option text and value need to be different. The text needs to be sorted alphabetically, whereas the Option value represents the Entity ID (guid).

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

18-11-2019

Hi,

Does the display id and saved value for drop-down need to be different?