Hi,
I am using Dynamics Nav 2009 classic. I need to sort list of records on a form that comes from one table.
Let’s say this is an item list. I need to sort it first by “Item Category Code” ascending, and then by “Product Group Code” descending. If I add those two fields as a key, it will take only one sort order, ascending or descending for both fields.
How I do it programmatically, maybe on “OnOpenForm” trigger?
Thank you.
You’re right of course, NAV with apply the Ascending/Descending property to the entire key, and not to individual fields within the key.
One solution might be to create a SQL query that accomplishes the sort order you want, then create a sql view that references the query. From there, you can create a linked object table that references the view. It’s a thought.
Thanks, I will try your suggestion with the sql query. But, isn’t really there a way in Nav to programmatically sort a table on multiple fields?
No, not in the way you’re trying to accomplish (field 1 ascending, field 2 descending …).
That being said, if I were being forced to produce the end result all within the NAV development environment, I would create a buffer table that would contain the data you’re interested in, and populate it in such a way that it sorts according to your requirements. This approach would not be very practical since you would have to populate the temporary buffer table every time a user opened the form, but it would accomplish the stated requirement.