Information Regaridng securrentkey function

hi good morning …

iam new to nav, i need some information regarding setcurrentkey function…

why setcurrentkey function…

where it shouuld be used

Table Keys

A table can have multiple keys. These keys are created by user to sort the data based on their requirement.


From multiple keys while during coding you can use any of the keys. When you dont specify any key it takes the Primary key of the table.

By specifying a key, it calculates fast and calcsum can also be used. So for faster execution of Reports and forms while displaying data or calculating data we use setCurrentkey.

What setcurrentkey Does

setcurrentkey temporarily sets the key of the record varibale as key specified by you.

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.