Thursday, December 13, 2018

Sorting data in a form datasource in Dynamics Ax 2012 / D365F&O X++

In Microsoft Dynamics AX, you can sort a form datasource when the form is loaded.

On the form, override the init method.

After the call to super(), add the sort field to the form datasource.

public void init()
{
    super();

    salesLine_ds.query().dataSourceTable(tableNum(SalesLine)).addSortField(fieldNum(SalesLine,         ConfirmedDLV), SortOrder::Ascending);
}

If you need to sort on multiple fields, keep adding the fields you need with the addSortField method.

public void init()
{
    super();
   
    salesLine_ds.query().dataSourceTable(tableNum(SalesLine)).addSortField(fieldNum(SalesLine,        ConfirmedDLV), SortOrder::Ascending);

    salesLine_ds.query().dataSourceTable(tableNum(SalesLine)).addSortField(fieldNum(SalesLine,        SalesStatus), SortOrder::Ascending);
}

1 comment:

Power Automate vs Azure Logic Apps vs Azure Data Factory: What They Are, When to Use Them, and How to Integrate Non-Microsoft Systems

  In today’s cloud-first, API-driven enterprise landscape, automation and integration have become vital pillars of operational agility. Micr...