Published On: November 6, 2020Categories: MS News, Technical


If you have a business requirement that requires saving the filtered query to use it later for all the users (whenever the user opens some form, this form will be opened as it is on the predefined query)– that means that you would need to make new development.

My requirement was the following:

For all users whenever they open this form “All project quotation” from “All Customers” the form should be opened as It is on the predefined query, and they wanted to be able to change this query when is needed.

Step-by-step instructions for Dynamics 365

1. The first step is to create a new table where you can save a filtered query. The field should be a type of container to save the query run. I made the logic for this table in such a way that there will always have only one record.


  2. Then we should create a new service class, controller, and contract to save the query.
For my requirement, I needed to save the SalesQuotationListPage_Proj query which is set on the property on the MenuItemDisplay – the menu item for the “All Project Quotation” form.

Picture2 1

Picture3 1

Picture4 1

Picture5 1

3. We need to create a new action menu item set the controller class on it, and to place this menu item somewhere in AX client so the user will be able to set this query as he wants.

4.  After saving this query on the table now we should change the query on the original form with the saved one. For this purpose, I made the extension on the CustTable form (because my requirement was this form to be opened by All customers). I added a new Command button and copy the event handler Clicked to write the logic.

Picture6 1


5. I created a new display menu item for the “All Project quotation” form and set the Form View Option to GRID. I made this because whenever I opened the form the detailed view was opened, this change helps me to solve that problem.

Picture7 1

    6. I Wrote a new event handler class and paste the event handler for the clicked method. You need to include the args.initialQuery()to set the saved query.

Picture8 1


Note: Also there is another way to change the query on the existing form, you can use Chain Of Command. New extension class for the “All project quotation ” from and put this code args.initialQuery(query) in the Init() method before next().