Muokkaa

Jaa


AutoFormatExpression Property

Version: Available or changed with runtime version 1.0.

Sets an AL expression that specifies how to format data.

Applies to

  • Table field
  • Page Field
  • Report Column

Syntax

AutoFormatExpression = '<Currency Code>';
AutoFormatType = 2;

Remarks

Applies to fields or columns of the decimal data type.

The AL expression is evaluated when the expression performs updates. Together with the AutoFormatType property, this property determines how data is formatted. These two properties are only used to format decimal data types, such as amounts that can be stated in a foreign currencies or ratios.

Learn more in Formatting decimal values in fields.

Example 1

The following example uses AutoFormatExpression property to set the format of decimal values to USD.

AutoFormatExpression = 'USD';
AutoFormatType = 1;

This example results in a value like 7,564.00.

Changing the AutoFormatExpression property to ÌRD sets the format of decimal values to IDR (Indonesian rupiah).

AutoFormatExpression = 'IRD';
AutoFormatType = 1;

This example results in a value like 7,564.

Example 2

The following example is similar to the previous example, except it adds a $ sign before the amount.

AutoFormatExpression = '1,USD';
AutoFormatType = 10;

This example results in a value like $7,564.00.

Example 3

This example prefixes the decimal value with a $, includes a thousand separator, and has a maximum of two decimal places, such as $76,453.21:

AutoFormatType = 1;
AutoFormatExpression = '$<precision, 2:2><standard format, 0>';

Example 4

Note

APPLIES TO: Business Central 2025 release wave 1 (v26) and later.

This example writes the number with two decimals, encloses the number in parenthesis if negative and 'Zero' if the value is 0. This uses the standard .NET numeric formatting system. Learn more in Custom numeric format strings.

AutoFormatType = 1;
AutoFormatExpression = '<FormatString>#,##0.00;(#,##0.00);Zero';

AutoFormatType property
DecimalPlaces property