# RecordRef.RecordId() Method
> Version: _Available or changed with runtime version 1.0._
Gets the RecordID of the record that is currently selected in the table. If no table is selected, an error is generated.
## Syntax
```al
RecordID :=   RecordRef.RecordId()
```
> NOTE
> This method can be invoked using property access syntax.
## Parameters
RecordRef
Type: recordref-data-type
An instance of the recordref-data-type data type.
## Return Value
RecordID
Type: ../recordid/recordid-data-type
The ID of the table.
## Example
The following example opens table 18 \(Customer\) as a RecordRef variable that is named MyRecordRef. The recordref-findlast-method finds the last record in the table. The record id of the last record is retrieved, stored in the RecID variable displayed in message box.
```al
var
    MyRecordRef: RecordRef;
    RecID: RecordId;
    Text000: Label 'The record id for the last record is: %1';
begin
    MyRecordRef.Open(18);
    MyRecordRef.FindLast;
    RecID := MyRecordRef.RecordId;
    Message(Text000, RecID);
end;
```
## Related information
recordref-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-recordid-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-recordid-method/
