Export (0) Print
Expand All

ERROR Function (Dialog)

Microsoft Dynamics Nav 2009

Displays an error message and ends the execution of C/AL code.

ERROR(String [, Value1, …])



Type: Text constant or code

This string contains the text of the error message you want to display to the user. Use percent signs (%) or number signs (#) to insert variable values into the string. Place the percent or number signs where you want to substitute the variable value. The string can be a text constant that is enabled for multilanguage functionality. For more information, see Working with Multilanguage Functionality.


Type: Any

Any variable or expression to be inserted in String. You can insert up to 10 values.

For '#'-type fields, the value is truncated according to the total number of number-sign characters in String. For '%'-type fields, the full length of the value is printed.

The window is automatically sized to hold the longest line of text and total number of lines.

We recommend the following guidelines for error messages:

  • Describe what is wrong and how to solve the problem.

  • Write a short descriptive message. Do not use more words than necessary.

  • Always end the error message with a period.

  • Use a text constant for the text of the message.

For more information, see Progress Windows, MESSAGE, ERROR and CONFIRM Functions.

This example shows how to use the ERROR function. The code example requires you to create the following variables and text constants in the C/AL Globals window.

Variable name DataType



Text Constant ENU Value


Finance Account #1#### must not be blocked.


Placeholder message.

AccountNo := 1230;
// The execution stops when the error statement is executed
// and all following statements will never be executed.
ERROR(Text000, AccountNo);
MESSAGE(Text001); // This line is not executed.

The error window displays the following:

Finance Account 1230 must not be blocked.

The ERROR function causes execution of C/AL code to stop. The MESSAGE function is never executed.

Community Additions

© 2014 Microsoft