{"title":"RecordRef.FieldIndex(Integer) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-fieldindex-method/","by":"JOP-AL","license":"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-fieldindex-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-fieldindex-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Gets the FieldRef of the field that has the specified index in the table that is referred to by the RecordRef.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"RecordRef.FieldIndex(Integer) Method","slug":"recordreffieldindexinteger-method","at":0,"chars":1835},{"level":2,"title":"Syntax","slug":"syntax","at":210,"chars":68},{"level":2,"title":"Parameters","slug":"parameters","at":278,"chars":165},{"level":2,"title":"Return Value","slug":"return-value","at":443,"chars":115},{"level":2,"title":"Remarks","slug":"remarks","at":558,"chars":300},{"level":2,"title":"Example","slug":"example","at":858,"chars":840},{"level":2,"title":"Related information","slug":"related-information","at":1698,"chars":137}],"text":"# RecordRef.FieldIndex(Integer) Method\n> Version: _Available or changed with runtime version 1.0._\nGets the FieldRef of the field that has the specified index in the table that is referred to by the RecordRef.\n## Syntax\n```al\nField :=   RecordRef.FieldIndex(Index: Integer)\n```\n## Parameters\nRecordRef\nType: recordref-data-type\nAn instance of the recordref-data-type data type.\nIndex\nType: ../integer/integer-data-type\nThe index of the field.\n## Return Value\nField\nType: ../fieldref/fieldref-data-type\nThe FieldRef of the field that has the specified index.\n## Remarks\nThe 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.\nIf the index is out of the range supplied or if no table is selected, then the method returns an error.\n## Example\n```al\nvar\n    SalesInvHdr: RecordRef;\n    FldRef: FieldRef;\n    Str: Text[1024];\n    Text001: Label 'Index 1: %1\\\\';\n    Text002: Label 'Index 2: %2\\\\';\n    Text003: Label 'Index 3: %3';\nbegin\n    SalesInvHdr.Open(112);\n    FldRef1 := SalesInvHdr.FieldIndex(1);\n    FldRef2 := SalesInvHdr.FieldIndex(2);\n    FldRef3 := SalesInvHdr.FieldIndex(3);\n    Message(Text001 + Text002 + Text003, FldRef1.Caption, FldRef2.Caption, FldRef3.Caption);\nend;\n```\nThe message window displays the following:\n Index 1: No.\n Index 2: Sell-to Customer No.\n Index 3: Bill-to Customer No.\n  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.\n## Related information\nrecordref-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}