# FieldRef.Length() Method
> Version: _Available or changed with runtime version 1.0._
Gets the maximum size of the field (the size specified in the DataLength property of the field). This method is usually used for finding the defined length of code and text fields.
## Syntax
```al
Length :=   FieldRef.Length()
```
> NOTE
> This method can be invoked using property access syntax.
## Parameters
FieldRef
Type: fieldref-data-type
An instance of the fieldref-data-type data type.
## Return Value
Length
Type: ../integer/integer-data-type
## Remarks
For Text and Code fields this method returns the defined length. For other types of fields, it returns the fixed byte size, for example, Integer fields returns 4.
## Example
The following example opens the Customer table as a RecordRef variable. The ../recordref/recordref-field-method creates a FieldRef for any specified field and stores the reference in the MyFieldRef variable. The LENGTH method retrieves the maximum size of the field and stores the value in the varLength variable. The value that is stored in the varLength is displayed in a message box.
```al
var
    MyFieldRef: FieldRef;
    CustomerRecref: RecordRef;
    varLength: Integer;
    varFieldNo: Integer;
    Text000: Label 'The maximum size of the field is %1.';
begin
    varFieldNo := 1;
    CustomerRecref.Open(Database::Customer);
    MyFieldRef := CustomerRecref.Field(varFieldNo);
    varLength := MyFieldRef.Length();
    Message(Text000, varLength);
end;
```
## Related information
fieldref-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

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/fieldref/fieldref-length-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. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/fieldref/fieldref-length-method/
