Gets the number of fields that have been defined in a key. Returns an error if no key is selected.
No := KeyRef.FIELDCOUNT
- Type: KeyRef The keyref that refers to the key.
Property Value/Return Value
The number of fields that have been defined in the key.
The following example retrieves the number of fields that are defined in a key in record. The table with ID 18 (the Customer table) is open with a reference to table 18. The KEYINDEX Function (RecordRef) function retrieves the second key in the record and store the KeyRef in the varKeyRef variable. The FIELDCOUNT Function (KeyRef) is then used to return the number of fields defined in the key and displayed in a message box. This example requires that you create the following variables in the C/AL Globals window.
RecRef.OPEN(18); varKeyRef := RecRef.KEYINDEX(2); VarCount := varKeyRef.FIELDCOUNT; MESSAGE('The number of fields defined in the key is: %1', VarCount);