Muokkaa

Jaa


RecordRef.FieldIndex(Integer) Method

Version: Available or changed with runtime version 1.0.

Gets the FieldRef of the field that has the specified index in the table that is referred to by the RecordRef.

Syntax

Field :=   RecordRef.FieldIndex(Index: Integer)

Parameters

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

Index
 Type: Integer
The index of the field.

Return Value

Field
 Type: FieldRef
The FieldRef of the field that has the specified index.

Remarks

The fields in the primary key are always listed first in the index. Therefore, the order of the fields in the index is not necessarily the same as the order of the fields in the table.

If the index is out of the range supplied or if no table is selected, then the method returns an error.

Example

var
    SalesInvHdr: RecordRef;
    FldRef: FieldRef;
    Str: Text[1024];
    Text001: Label 'Index 1: %1\\';
    Text002: Label 'Index 2: %2\\';
    Text003: Label 'Index 3: %3';
begin
    SalesInvHdr.Open(112);  
    FldRef1 := SalesInvHdr.FieldIndex(1);  
    FldRef2 := SalesInvHdr.FieldIndex(2);  
    FldRef3 := SalesInvHdr.FieldIndex(3);  
    Message(Text001 + Text002 + Text003, FldRef1.Caption, FldRef2.Caption, FldRef3.Caption);  
end;

The message window displays the following:

  • Index 1: No.

  • Index 2: Sell-to Customer No.

  • Index 3: Bill-to Customer No.

The following illustration shows the first fields in table 112, Sales Invoice Header, and shows the keys for table 112. The order of the fields in the index differs from the order of the fields in the table. The index lists the field in the primary key first.

RecordRef Data Type
Get Started with AL
Developing Extensions