Information Regaridng securrentkey function

You use the SETCURRENTKEY to “set the current key” of the table you are working on to specify how you want NAV to sort your data of that table. Take a table like the Customer Ledger Entries. If you do not specify SETCURRENTKEY in your code, then it will sort everything by Entry No. (the primary key) and typically you don’t want that.

SETCURRENTKEY is also important when it comes to performance. You typically want to included the fields you are filtering on in the selected key. Especially if you are using the native database. With SQL Server it depends on how your server has been configured.

You can only use keys which previously has been added to the table from the table designer.