SourceTableView Filters vs Manual Coding Filters

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,
Tharanga Chandrasekara

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

8 comments

Skip to comment form

  1. Thanks Tharanga for sharing this…

  2. Your welcome. Hope it was informational for you.

  3. thanks tharanga for this information

    • Unknown on September 22, 2015 at 4:05 am

    Your welcome.

    • Anonymous on December 9, 2015 at 2:35 am

    Thanks for this.
    I was trying to apply the same concept to the Customer table.
    As I was wanting to the Balance (LCY) to Credit Limit (LCY) unfortunately, it was not liking the comparison and was throwing a decimal error:

    WHERE(Balance (LCY)=FILTER(>Credit Limit (LCY)))

    Do you have any suggestions?
    Thanks

    • Unknown on February 29, 2020 at 10:24 pm

    Hi,

    With the source table view property can we add two filter on one field?

    • Fredrik Ekström on March 31, 2021 at 2:29 am

    Hi!
    What about in BC?

    • samuel on June 30, 2021 at 2:30 pm

    The real difference, is where the filter work.
    When the filter will be in the server.
    With SETFILTER, the filter will be on client.

    Regards

Comments have been disabled.