FIELDINDEX Function (KeyRef)
Gets the FieldRef of the field that has this index in the key referred to by the KeyRef variable. Returns an error if no key is selected.
FieldRef := KeyRef.FIELDINDEX(Index)
The KeyRef that refers to the key.
The input index.
Property Value/Return Value
The FieldRef that refers to the field with this index in the key.
The first field in the index must have index 1, the second index 2, and so on. The last field must have index = FIELDCOUNT. If the index is out of the range supplied or if no table is selected, the function returns an error.
The following example displays the caption of a field in a record. The table with ID 18 (the Customer table) is open with a reference. The Keyref for the record is retrieved by using the KEYINDEX Function (RecordRef). The function retrieves the second key in the record and stores the value in the varKeyRef variable. The varKeyRef variable is then used to return the FieldRef. The varFieldRef variable is used to display the caption of the field. This example requires that you create the following variables in the C/AL Globals window.
RecRef.OPEN(18); varKeyRef := RecRef.KEYINDEX(2); varFieldRef := varKeyRef.FIELDINDEX(1); MESSAGE('The Field name is: %1' ,varFieldRef.CAPTION);
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.