When you create a form in D365, you will often show a grid that displays records from a table. However, there are many cases when you do not want to show all of the records from the table. Perhaps you only want to show records with a certain status. In this article I will show you how to filter data in D365 forms.
This article will mostly cover the functional ways to filter data. In this next article I will explain how to write override the executeQuery method and use x++ code to filter data.
Ways To Filter Data
In Microsoft Dynamics Dynamics 365 for Finance and Operations there are several ways to filter data shown on a form. It is important to understand the different ways data can be filtered. This way, when you decide to create a new form, you can decide what way will provide the best experience for the end user.
As part of the base Microsoft grid controls, there is built in functionality that allows data to be filtered. Additionally, there are other ways of filtering data on a form, that can only be done by an x++ developer. There is some Microsoft documentation on this topic. But I wanted to share my own understanding of how to filter data in D365 forms.
Filter Pane
A filter Pane is a filter that slides in from the left. It allows the user to add multiple criteria on the left side. This is similar to the filters you can apply to the columns on a grid. But it is useful on forms that do not have a grid.
Go to Cost management > Inventory accounting > Released products.
Click the filter botton on the left side:
In this pane, users can add filters to various fields on the form. Click the Add button to add additional filets to the filter pane.
In the dialog that opens, enter in ‘product name’ and hit enter.
Select the checkbox under the column ‘Select’ and then push the ‘Update’ button’.
The filter pane will now look like this:
Click on the blue text ‘begins with’ and change the drop down to be ‘contains’.
Enter the word ‘tire’ into the filed. Then click the Apply button.
You will see that the results are not filtered to only show products with the word ‘tire’ in their product name field.
Advanced Filter/Sort
The Advanced filter refers to the ‘Select’ button that appears on some forms. Let’s look at an example.
Go to Accounts receivable>Invoices>Batch invoicing
Click the ‘Select’ button.
In the dialog that shows, you can add fields to the grid that are part of the underlying query. You can then add filter values to those fields. This is done by entering values in the ‘Criteria’ column.
For example, in this form, the invoice process is setup to only run against sales orders where the status is between open order and delivered. We can change this to run against only orders with a particular customer account, for instance.
Quick Filter
The Quick Filter control is a control that was only available in list pages in Dynamics AX 2012. Now however, in D365, the Quick Filter control can be added associated with any grid control. It is a best practice to add this control above a grid. It allows a user to enter in a filter value. A dialog pop up will show that lists out all of the columns in the grid. The user can then select one, and the system will then filter the grid based on that value and column. Take a look at this example from the ‘all sales orders’ form.
In this previous article, I explained how to create a form, which includes a Quick Filter control and a grid.
Grid Header
Many of the forms in D365 will use a Grid control. The grid control shows rows and columns from one or more datasources on the form. The datasources relate to tables, views or queries. As long as the column in the grid relates to a field on a datasource, then it can be filtered. There are however some columns that use display methods, or edit methods. Columns that are shown using a display method or edit method cannot be filtered.
Navigate to the ‘all customers’ form in D365 as an example. Click on the label header at the top of any column. A drop down dialog will appear. The user can use this dialog to filter the data in the grid by this column.
There are several options that can allow a user to type in only a part of a value. But still filter on the field.
A user can filter on as many columns on the grid as they want until they are able to view the data they are looking for. This gives the user a lot of control. However it does require manual steps. Overwriting the init method or the executeQuery method on the datasource in code provides a way to filter the data either when the form first opens, or based on user interaction.
Conclusion
In conclusion, these are some of the functional and general ways to filter data on a form. In the next article I will show you how to override the executeQuery method on a form’s datasource to filter data on a form. Doing this allows for more specific ways of filtering the data.
Hi Peter,
I just started my job as Dynamics 365 AX FinOps Solution engineer and your videos are really helpful! I eagerly wait whole week for your new video. I would like to request you to create a video where you can explain how and where to perform calculations when a field is changed in a form!
I am so glad you have enjoyed my videos! I should be able to create a video covering what you are asking.
Hi Peter.ramer,
I’m a new Software developer trainee in Microsoft Dynamics 365 Finops, I’m still learning and exploring these dynamics. Can you help with the Advanced Filter concept and how to implement it in a form-level method by using SysQuery::findOrCreateRange(parameter)?
I recommend reading my article on executequery. That tells you how to write x++ code to filter data on forms in more advanced ways and can use the method you just shared. Let me know if that doesn’t give you what you are looking for.
Yes, it did work. Thanks alot. Your blogs are very useful.
Glad to hear! Thanks!
Hey peter.ramer!
I need to calculate the total net amount by adding the calculated tax from the salesline standard table, where calculated tax is a custom field that is created using the extension of the standard table. Could you help me out? how to add calculated tax to the net amount.
You can look at the methods on the saleline table. There should be a method with lineamount in the name. That method calculates the net amount for the line. You can extend that to add in tax if you want. I would caution you as sometimes tax is included and sometimes it is not included in the sales line net amount based on a flag on the sales order header. You can also check out this link for getting totals for the entire order. https://dynamics365musings.com/d365-sales-order-totals/#:~:text=View%20The%20Sales%20Order%20Totals&text=First%2C%20in%20D365%2C%20go%20to,orders'%20in%20the%20search%20bar.
Sure Thank You!
Hi Peter.ramer,
is there a way to use a ‘list’ in a filter of ‘is not’. similar to how ‘is one of’ works? maybe a filter of ‘is not one of’?
Yes. Let me double check the specific syntax but I believe you can write into the filter something like !(value1, value2, value3).
The exclamation indicates ‘not’. So maybe it is !value1, !value2. But let me check on that. Good question.