{"title":"TestField.Caption() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/testfield/testfield-caption-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/testfield/testfield-caption-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/testfield/testfield-caption-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 current caption of the field as a String.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":111,"chars":118},{"level":2,"title":"Parameters","slug":"parameters","at":229,"chars":100},{"level":2,"title":"Return Value","slug":"return-value","at":329,"chars":98},{"level":2,"title":"Remarks","slug":"remarks","at":427,"chars":356},{"level":2,"title":"Example","slug":"example","at":783,"chars":796},{"level":2,"title":"Related information","slug":"related-information","at":1579,"chars":137}],"text":"> Version: _Available or changed with runtime version 1.0._\nGets the current caption of the field as a String.\n## Syntax\n```al\nResult :=   TestField.Caption()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n## Parameters\nTestField\nType: testfield-data-type\nAn instance of the testfield-data-type data type.\n## Return Value\nResult\nType: ../text/text-data-type\nThe current caption of the field as a String.\n## Remarks\nCaption returns the caption of a field. Caption first looks for a ../../properties/devenv-captionml-property.\nIf it does not find one, it will use the Name Property<../../properties/devenv-properties>. This means that Caption is enabled for multilanguage functionality.\nThis method is similar to the ../record/record-fieldcaption-method method.\n## Example\nThe following example opens table 18 \\(Customer\\) as a RecordRef variable that is named CustomerRecref. The code uses the ../recordref/recordref-field-method to loop through field 1 through 9 and creates a FieldRef variable that is named MyFieldRef. For each field, the Caption method retrieves the caption of the field, stores it in the varCaption variable and displays it in a message box.\n```al\nvar\n    CustomerRecRef: RecordRef;\n    MyFieldRef: FieldRef;\n    varCaption: Text;\n    i: Integer;\n    Text000: Label 'The caption for field %1 is \"%2\".';\nbegin\n    CustomerRecref.Open(18);\n    for i := 1 to 9 do begin\n      MyFieldRef := CustomerRecref.Field(i);\n      varCaption := MyFieldRef.Caption;\n      Message(Text000, i, varCaption);\n    end;\n    CustomerRecref.Close;\nend;\n```\n## Related information\ntestfield-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}