Bearbeiten

Freigeben über


Dialog.Error(Text [, Any,...]) Method

Version: Available or changed with runtime version 1.0.

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

Syntax

 Dialog.Error(Message: Text [, Value: Any,...])

Note

This method can be invoked without specifying the data type name.

Parameters

Message
 Type: Text
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 label that is enabled for multilanguage functionality.

[Optional] Value
 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.

Remarks

The window is automatically sized to hold the longest line of text and total number of lines. By calling the method with an empty string the execution of AL code ends without displaying a message.

Note

Consider using the newer version of the Dialog.Error method Dialog.Error(ErrorInfo) Method to use many of the newer features in error dialogs, such as (hidden) detailed error messages for the person who needs to troubleshoot, error message titles, and support for actionable errors.

Guidelines for error messages

Improving error handling and error messages reduces friction for the users and highly impacts the user experience. Clear and informative error messages help users understand what went wrong and how to correct it, which reduces frustration, and improves user satisfaction.

For guidance on how to formulate good error messages, see Error message best practices - what to say?.

Example

This example shows how to use the Error method.

var
    AccountNo: Integer;
    Text000: Label 'Finance Account #1#### must not be blocked.';
    Text001: Label 'Placeholder message.';   
begin 
    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.  
end;

The error window displays the following:

Finance Account 1230 must not be blocked.

The Error method causes execution of AL code to stop. Message Method is never executed.

Dialog.Error(ErrorInfo) method
Error handling overview
Analyzing Error method telemetry
Dialog data type
Get started with AL
Developing extensions