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?
Views
Replies
Total Likes
Hi,
Does the display id and saved value for drop-down need to be different?
Views
Replies
Total Likes
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).
Views
Replies
Total Likes
send me sample JSON that you are getting and let me try something.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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);
Views
Replies
Total Likes
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
Views
Replies
Total Likes
It might not be documented but we know it exists and work.
Views
Replies
Total Likes