In Microsoft Dynamics NAV you can set the filters in two main different ways,
01. By using the SourceTableView Filter
02. By using the Setfilter or Setrange in the coding level.
What has the higher preceding? Have you ever tried?
In order to check this I have created a new page.
Source Table : Gen. Journal Line (81)
It shows all the available records in the Gen. Journal Line.
In the OnOpenPage trigger I add the following filter code. This code will filter the page Rec to provided document number.
As you can see page Rec has filtered to our given value, and also under the page filters it shows the current filters. Addition to that you will have the ability to remove or change the filter as your wish.
To check the SourceTableView filters I have removed the previous code and add the following filters in the page properties.
When I run the page with the new modification, it also get filtered to the provided value, but one thing to notice is you will not be able to clear the filters and will not show the current filters as well.
This is not what we wanted to check, to check which filters have the higher proceedings, I have put both the filters to the page.
Below is a screenshot of the result page.
No records in the page, yet page filter shows it has filtered to the document number “SLI-CUS-15-00033”. This is the document number we have provided in the OnOpenPage trigger. So something is going on in the background, to understand that I have cleared the filter which was applied for the document number “SLI-CUS-15-00033”.
As I clear the filter for the document number “SLI-CUS-15-00033”, page showed a one record. This is the document number we have given in the SourceTableView Filters.
What is happening in the background?
As soon as you run the page, Microsoft Dynamics NAV will filter the rec depending on the filters you have set in the SourceTableView property. After that only page will go through the code that has been written in the OnOpenPage trigger or any trigger available.
Beauty of this is even if you have filters for the same fields (in this scenario Document Number), Microsoft Dynamics NAV will set the manual filters on top of the SourceTableView property.
Please provide your feedback with a comment.
Thank you and Regards,