{"title":"CaptionClass Property","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/properties/devenv-captionclass-property/","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/properties/devenv-captionclass-property, 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/properties/devenv-captionclass-property","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":"Controls the caption that is used in the label of a field in a database table or in the label of a control on a page.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Applies to","slug":"applies-to","at":178,"chars":51},{"level":2,"title":"Syntax","slug":"syntax","at":229,"chars":235},{"level":2,"title":"Remarks","slug":"remarks","at":464,"chars":3279},{"level":3,"title":"Caption Class","slug":"caption-class","at":1979,"chars":1764},{"level":2,"title":"Related information","slug":"related-information","at":3743,"chars":131}],"text":"> Version: _Available or changed with runtime version 1.0._\nControls the caption that is used in the label of a field in a database table or in the label of a control on a page.\n## Applies to\n Table field\n Page Label\n Page Field\n## Syntax\n```al\nCaptionClass = '3, My awesome caption';\n```\nThe CaptionClass property must be expressed in the format `'<Caption Area>, <Caption Expression>'`. Both `<Caption Area>` and `<Caption Expression>` are alphanumeric strings.\n## Remarks\nWhen you set the CaptionClass property on a field, users can configure the caption of a text box or the caption of a check box without having to modify the code. The `Caption Class` (codeunit 42) in the system application layer then translates the CaptionClass property into actual captions that will be displayed in the UI. For example, if `CaptionClass = '3, My awesome caption';` the resulting caption in the UI will be My awesome caption.\n> NOTE\n> `<Caption Area>` is the location of the caption you want to use. The `<Caption Area>` can be '50000', '50140', and so on. Or, it can be a code from among 1, 2, and 3, which are handled by the base application layer and have a special meaning.\n > 1 is for using a Dimension as caption.\n > 2 is for captions of fields that can include or not VAT. For example, if `CaptionClass = '2,0,Invoice Amount';` the resulting caption in the UI will be Invoice Amount Excl. VAT. If `CaptionClass = '2,1,Invoice Amount';` the resulting caption in the UI will be Invoice Amount Incl. VAT.\n > 3 returns the `<Caption Expression>` string. In the example in the above section, \"3\" returns the `<Caption Expression>` that is My awesome caption.\n> IMPORTANT\n> If you omit the pattern of `'<Caption Area>, <Caption Expression>'`, the caption becomes the value of whatever string has been given to the CaptionClass property. This means that you can use an expression such as `CaptionClass = ItemRec.Fieldcaption(\"Location Code\");` as long as the returned data type is Text.\n### Caption Class\nThe `Caption Class` (codeunit 42) in the system application exposes two events; the OnResolveCaptionClass and the OnAfterCaptionClassResolve event.\nFor more information, see the system https://github.com/microsoft/BCApps/tree/main/src/System%20Application/App/Caption%20Class.\nThe Caption Class raises an OnResolveCaptionClass event for any other value of `<Caption Area>`.\n```al\n[IntegrationEvent(false, false)]\n    internal procedure OnResolveCaptionClass(CaptionArea: Text; CaptionExpr: Text; Language: Integer; var Caption: Text; var Resolved: Boolean)\n    begin\n    end;\n```\nThe OnAfterCaptionClassResolve event is used to overwrite the above logic, in case the CaptionClass property isn't the expected format or if some extra logic needs to be added.\n```al\n[IntegrationEvent(false, false)]\n    internal procedure OnAfterCaptionClassResolve(Language: Integer; CaptionExpression: Text; var Caption: Text[1024])\n    begin\n    end;\n```\nThe following example shows an implementation of the OnResolveCaptionClass event.\n```al\ncodeunit 50000 \"MyCaptionClassMgmt\"\n{\n    [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Caption Class\", 'OnResolveCaptionClass', '', true, true)]\n    local procedure MyOnResolveCaptionClass(CaptionArea: Text; CaptionExpr: Text; Language: Integer; var Caption: Text; var Resolved: Boolean)\n    begin\n        if CaptionArea = '50000' then begin\n            Caption := GetCaption(CaptionExpr);\n            Resolved := true;\n        end;\n    end;\n\n    local procedure GetCaption(CaptionExpr: Text): Text\n    var\n        CaptionALbl: Label 'Caption a)';\n        CaptionBLbl: Label 'Caption b)';\n    begin\n        if CaptionExpr.Contains('A') then\n            exit(CaptionALbl);\n        exit(CaptionBLbl);\n     end;\n}\n```\n## Related information\ndevenv-captionml-property\ndevenv-caption-property\n../methods-auto/system/system-captionclasstranslate-method"}