Hi all
I want to add a method into a lookup form to sort the Invoice Date , descending
I want to know if I fill the code in the init or queryexecution?
Im new on D365 , I need also please an exemple from A to Z with the code .
Thank you
Hi Goergio,
You can write code in the data source init method to add the field you want to sort it by (Invoice date in your case). You can check this post for an example.
How I can Override the init() method of data source into a class
What should I write
Which form are you working on? Is it a standard form?
No customized one
Just please I need exemple any form
So, this is a lookup form . Correct?
You can right click on data source methods an choose override and select init.
You can check the ProjTableLookup form as an example, which has an init method.
And what should I put in my code after I override the method
Please I need a full code
Thanks man
Since this is a customized form, I am not sure of the datasource and field names. You can follow the post I provided in the beginning.
Your code will look like this -
this.queryBuildDataSource().addSortField(fieldNum(, InvoiceDate),SortOrder::Descending);
You can replace <yourTable> with the table name (that you are using in the data source).
Only I have to add this line of code? And
That should be all for sorting by the field.
this.queryBuildDataSource().addSortField(fieldNum(<YourTable>, InvoiceDate),SortOrder::Descending);
In the place of <YourTable> you place your table name and as you said the field you want to sort is InvoiceDate. So copy the field name and paste it here in the place of InvoiceDate
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,177
André Arnaud de Cal... 860 Super User 2025 Season 2
Sohaib Cheema 593 User Group Leader