Sort the grid on the formdatasource using INIT method

 Today we have a requirement when the forms open we want to sort the field in the Decending order.


Below is the code that's helps to achieve it.

===========================================================================

Code :- 

[ExtensionOf(formDataSourceStr(ProdSchedule, ProdTable))]

final class AVAProdSchedule_Extension

{

   

      public void init()

    {

        next init();

        this.avaSortPriority();

    }


    /// <summary>

    ///  This method is used to sort the production order with Priority field in descending order.

    /// </summary> 

    public void avaSortPriority()

    {

        FormDataSource prodtableDS = element.dataSource(formDataSourceStr(ProdSchedule, ProdTable));

        prodtableDS.query().dataSourceTable(tablenum(ProdTable)).addSortField(fieldnum(ProdTable, ProdPrio), SortOrder::Descending);

    }


}


=========================================================================

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++