Monthly Archives: February 2020

The RecordID Datatype

When you declare a local or global var you could specify the RecordID datatype in Microsoft Dynamics NAV like this:

C/AL Locals Window

So what does this data type exactly holds? I was curious as ever to found out and started reading Microsoft Docs. This data type contains the table name and primary key values of a record in a certain table. Not a surprise (for you) but for me it was: you can store a recordID in a field with datatype RecordID also. When you view the recordID field contents in the client it’s not visible:

RecordID value displayed in the Windows Client

I’m curious what it exactly holds so I started writing some code in a codeunit and runned it:

RecRef.OPEN(DATABASE::Customer);
RecRef.FINDLAST;
RecID := RecRef.RECORDID;
MESSAGE('%1',RecID);

The code above opens the customer table, finds the last record and displays a message with the contents of the RecID variable.