Editar

Compartir vía


CaptionClass Property

Version: Available or changed with runtime version 1.0.

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.

Applies to

  • Table field
  • Page Label
  • Page Field

Syntax

CaptionClass = '3, My awesome caption';

The CaptionClass property must be expressed in the format '<Caption Area>, <Caption Expression>'. Both <Caption Area> and <Caption Expression> are alphanumeric strings.

Remarks

When 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.

Note

<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.

  • 1 is for using a Dimension as caption.
  • 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.
  • 3 returns the <Caption Expression> string. In the example in the above section, "3" returns the <Caption Expression> that is My awesome caption.

Important

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.

Caption Class

The Caption Class (codeunit 42) in the system application exposes two events; the OnResolveCaptionClass and the OnAfterCaptionClassResolve event.

For more information, see the system Caption Class.

The Caption Class raises an OnResolveCaptionClass event for any other value of <Caption Area>.

[IntegrationEvent(false, false)]
    internal procedure OnResolveCaptionClass(CaptionArea: Text; CaptionExpr: Text; Language: Integer; var Caption: Text; var Resolved: Boolean)
    begin
    end;

The 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.

[IntegrationEvent(false, false)]
    internal procedure OnAfterCaptionClassResolve(Language: Integer; CaptionExpression: Text; var Caption: Text[1024])
    begin
    end;

The following example shows an implementation of the OnResolveCaptionClass event.

codeunit 50000 "MyCaptionClassMgmt"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Caption Class", 'OnResolveCaptionClass', '', true, true)]
    local procedure MyOnResolveCaptionClass(CaptionArea: Text; CaptionExpr: Text; Language: Integer; var Caption: Text; var Resolved: Boolean)
    begin
        if CaptionArea = '50000' then begin
            Caption := GetCaption(CaptionExpr);
            Resolved := true;
        end;
    end;

    local procedure GetCaption(CaptionExpr: Text): Text
    var
        CaptionALbl: Label 'Caption a)';
        CaptionBLbl: Label 'Caption b)';
    begin
        if CaptionExpr.Contains('A') then
            exit(CaptionALbl);
        exit(CaptionBLbl);
     end;
}

CaptionML Property
Caption Property
CaptionClassTranslate Method