Gets the FieldRef of the field that has the specified index in the table that is referred to by the RecordRef.
Field := RecordRef.FIELDINDEX(Index)
- Type: RecordRef
- Type: Integer
Property Value/Return Value
The FieldRef of the field that has the specified index.
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 function returns an error.
This example requires that you create the following variables and text constants in the C/AL Globals window.
|Text constant name||Constant value|
Index 1: %1\
Index 2: %2\
Index 3: %2
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);
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, when you design the table in Object Designer, 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.