Working with labels

Note

We're working on improving the onboarding experience for AL developers. If you've input for this article, we'd love to hear from you. Please use the Feedback section at the bottom of this article to help us make improvements that you’d like to see.

We also welcome contributions to our docs. New to contributing to docs? Don't worry, read more about contributing here Contribute to the help.

Labels are string constants displayed in the Business Central client that can be translated into multiple languages, such as captions, descriptions, or messages. This way, the user interface can be displayed in different languages. For more information on how translation is carried out in Dynamics 365 Business Central, see Multilanguage development.

Label syntax

Labels have a specific syntax defined by a text constant followed by three optional parameters. They must be comma-separated, but the order of the parameters isn't enforced. The parameters that you can set are described in the following table.

Parameter Type Description
Comment Text Used for general comments about the label, specifically about the placeholders in that label.
Locked Boolean When Locked is set to true, the label shouldn't be translated. The default value is false.
MaxLength Integer Determines how much of the label is used. If no maximum length is specified, the string can be any length.

Using labels

A label can take the form of four different AL structures. It can be the property value of certain page and report properties, the label data type variable, and a report or a page label. The different possibilities are explained in more detail in the following section.

Properties

The label syntax is used in properties that are set to display text on the user interface. It applies to the following properties:

The following example shows the label syntax when it's used as property value for the Caption property.

Caption = 'Developer translation for %1',  Comment = '%1 is extension name', locked = false, MaxLength=999;

Label data type

The Label Data Type denotes a string variable used to define error messages, questions, captions, tokens, or other text constants displayed to the user.

The following code sample illustrates how to use the Label data type. The Comment, MaxLength, and Locked parameters are optional, but they can be used to provide additional information about the label. In the following example the label text is locked for translation and has a maximum length of 999 characters.

var
    a : Label 'Label Text', Comment='This label shouldn't be translated.', MaxLength=999, Locked=true;

Tip

With Business Central 2023 release wave 2, you can hover over any variable of the Label data type to see the text string value of the label.

The Label variable names should have an approved suffix. For more information, see CodeCop Rule AA0074.

Report labels

Report labels are used by report layouts as, for example, the caption for a field, the title for a chart, or the title for the report itself.

For more information about labels, see Report labels.

Page labels

Page labels are used to display plain text on a page, such as instructions or informative texts. You can find several examples of page labels in the RapidStart Services Wizard in page "Config. Wizard".

Page labels are defined by a label(Name) control inside the area(Content) part of a page. The following code shows how to define a page label.

label(BeforeSetupCloseMessage)
{
    ApplicationArea = Basic, Suite;
    Caption = 'If you still need to change setup data, don''t change the profile.'
}

See also

Working with labels
Working with translation files
Label data type
Report layouts