How to set/change the default sorting order of a page in Microsoft Dynamics NAV

Over the past few weeks I noticed there were several forum queries regarding how to sort a page with a different key. So thought to write a small blog post about how to do.

As the example I would take customer ledger entry page in Microsoft Dynamics NAV 2015. As you see in default system set the “Entry No.” as the default sorting key. 

How system works and how did system identify the default sorting key. 
In Microsoft Dynamics NAV developer can set the sorting key in the page itself. If the sorting key is not set in the page level then system set the page sorting order depending on the primary key of the table. 

Why to set a default sorting key when user can set the sort order by clicking the header the column (Caption). 

Yes, It is true that user can set the sorting order by himself, but it is a manual process and every time user open the page he/she should be click on a column to set the sort key. So why not set a default sort key, because it save the time, and computer resource. 

Let’s start with the tutorial. 

In this case I want to set Customer Ledger Entry page default sorting key as Posting Date. 

In order to perform this I want to have a active key in the source table. In this case my source table is Cust. Ledger Entry table. 

So I design my Cust. Ledger Entry table in the development environment. 

Then go to Tools -> Keys
It will open a window like below, and in the last line I add my new key, which is the Posting Date. 

After adding the key to the table I saved and compiled my Cust. Ledger Entry table. 

We are done with the table modification and now we have to set the key to the page. In order to do that I have to open the Customer Ledger Entries page in the development environment. 

Below how it look like once you open the page in the design view, Click on the first empty line of the page design view. 

Then click on the properties icon in the top toolbar. By doing that system will open a properties window of the page. 

Remember this is where many of the new developers make the mistake. In order to get the page properties you need to click on a empty line and then click on the properties. 
If you click on any other row and then click properties will open the properties of that particular row. 

Once you click on the Page property following screen will open. First check the Name field in the list. It should be as the page Name and if the name field has a different name than the page name, that means you must have opened a property of a field. 

In the following page as you can see source table is set as the Cust. Ledger Entry and Source Table View is empty. That means system will get the sort key from the source table. In this case Entry No. 
So we want to change it to Posting Date. 
To do that click on the drilldown button in the SourceTableVeiw.

Once you click on the SourceTableVeiw  drilldown system will open up the following window where you will be able to set your key for the page. 

As the window below set the key and set the order you want to have. 
When you click on this it will show all the active keys for the page and you have to select your key. In this case I will select Posting Date as my key.  

Once you click on the OK button, window will get closed and SourceTableVIew field will be filed with the key and the order you sorted in the previous window. 

Esc. from the properties window and then compile and save the page. 

We are ready to go. To check the modification, open the page in RTC and as you can see default sorting is set to the Posting Date. 

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?


Skip to comment form

  1. Hi thanks for a fine blog
    I sort on the posting date descending because i want to see the current postings and not what happent 2-3 years ago 🙂

    But after sorting descent the form opens on the oldest record still? (at the button of the screen)
    I found that

    • Anonymous on October 20, 2017 at 1:54 am

    Ƭhіs wеbsite was… how do yоu sɑy it? Relеvant!! Finally I've found something which helped
    me. Many thanks!

    • Anonymous on October 20, 2017 at 1:54 am

    Wheen I originally commented I clicked the "Notify me when new comments are added" checkbox and now each ime a comment is added I get three
    emails with the same comment. Is there any way youu can remove people from that service?


    • Unknown on October 20, 2017 at 2:01 am

    Glad it helped.

    • Anonymous on December 30, 2017 at 10:40 am

    It changed the sorting, but now my scroll bar starts at the bottom vs the top?
    Anything to correct that so it starts at the 'top' again. Otherwise its really no better than it was before.

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

    Thank you! This works great for me. I could change the default setting for opening the page. But when opening the page over a link from a flow field (f.e. in the item card) the "old sorting" is shown. It forwards some filters to the page – is there also a way to forward the sorting? Many Thanks!

Comments have been disabled.