web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

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

Rahul Kiran Profile Picture Rahul Kiran 481
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);
}


This was originally posted here.

Comments

*This post is locked for comments