Modifier

Partager via


Record.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

RecordID :=   Record.RecordId()

Note

This method can be invoked using property access syntax.

Parameters

Record
 Type: Record
An instance of the Record data type.

Return Value

RecordID
 Type: RecordId

Remarks

You can show strings that include RecordId in the user interface by using the Format method). In most cases, use the standard format value 1, which ensures that captions are shown in the current language. The following table illustrates the effect of the different standard formats when RecordId is used in a Format statement in a Danish locale.

Standard Format Renders as
Format(Customer.RecordId,0,0) Customer: 1212121
Format(Customer.RecordId,0,1) Kunde: 1212121
Format(Customer.RecordId,0,9) Customer: 1212121

When you use standard format 1, the caption of the record is returned. When you use other standard formats, the name of the record is returned, which is usually English (US). Learn more in Format property.

Example

The following example opens the Customer table as a Record variable that is named MyRecord. The 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.

codeunit 50112 GetRecordId
{
    trigger OnRun()

    var
        MyRecord: Record Customer;
        RecID: RecordId;
        MyTextConst: Text; 

    MyRecord.FindLast;  
    RecID := MyRecord.RecordId;  
    Message(MyTextConst, RecID);  // The record ID for the last record is: %1

    end;
}

Record Data Type
Get Started with AL
Developing Extensions