A page field control includes the Style Property that you use to format the text that displays in a page field. The Style property has four values that apply different formats to field text. The format that is applied to a field in Edit mode is different than the format that is applied in View mode. The following table describes the four values and the corresponding format in Edit and View modes.

Value Format in Edit mode Format in View mode

Strong

Bold

Bold

Attention

Red

Default

Favorable

Bold + Green

Bold

Unfavorable

Bold + Italic + Red

Bold + Italic

By using the field's StyleExpr Property, you can apply the formatting to the field at all times or based on the field's data.

Always Applying a Format to Text in a Page Field

Use the following procedure to apply formatting to field text on a page at all times.

To format field text always

  1. Open the page in Page Designer.

  2. Select the field that you want to format, and on the View menu, click Properties.

  3. Set the Style property value to one of the formats that are described in the preceding table.

  4. Set the StyleExpr property value to true.

Applying a Format to Text in a Page Field That Is Based on the Field's Data

By using a page field's StyleExpr property, you can apply the format that is specified by the Style property to a field based on the field's data. For example, you can display text in red if the value of the field is a negative number, italic red if an item is low in stock, or bold green to indicate a favorable value, such as a high credit limit.

To set up this formatting, you define a Boolean variable and add C/AL code to the page that evaluates the field's data. The C/AL code should return the Boolean variable as True when the data meets the conditions for which you want to apply the formatting. You then set the variable on the field's StyleExpr property.

To define the variable to use to format field text

  1. Open the page in Page Designer.

  2. On the View menu, click C/AL Globals.

  3. Define the variable, and then set the DataType to Boolean.

  4. On the View menu, click Properties to open the variable's properties, and then set the IncludeInDataSet to Yes.

    NoteNote

    If the IncludeInDataSet Property is not set to Yes, then when you run the page, you will receive an error that states that the identifier variable could not be found.

  5. On the View menu, click C/AL Code, and then add C/AL code that sets the variable.

    NoteNote

    The variable must evaluate to true.

To set the variable to the StyleExpr property of the page field

  1. In Page Designer, open the Properties of the field that you want formatted.

  2. Set the Style property value to one of the formats that are described at the beginning of this topic.

  3. Set the StyleExpr property value to the variable that you defined in the previous procedure.

See Also