Error Message Display Location in Oracle APEX
The error message display location identifies where a validation error message displays. Validation error messages can display on an error page or inline within the existing page. Inline error messages can display in a notification area (defined as part of the page template) or within the field label.
To create a hard error that stops processes, including any remaining validations, you must display the error on an error page.
In Oracle APEX, error messages guide users when something goes wrong, such as missing required fields, incorrect data formats, or system errors. APEX provides various options to control where error messages appear, improving user experience and making it easier for users to correct mistakes.
This tutorial explains the different error message display locations in APEX and how to configure them for different scenarios.
Types of Error Messages in APEX
Error messages in APEX can be triggered by:
Validations – Enforce required fields, check data formats, or validate data against business rules.
Process Errors – Occur when a database operation (such as inserting or updating data) fails.
Session State Errors – Triggered when items are missing required values.
Application Errors – Generated by PL/SQL code, such as raising an exception.
Depending on the type of error, you can choose different display locations to make messages more visible and user-friendly.
Configuring Error Message Display Locations
APEX allows error messages to be displayed in different areas of a page. The most common locations are:
1. Inline with Field (Below or Above the Field)
This displays an error message directly below or above the field where the issue occurred.
Best for form-based validations where the user needs immediate feedback on incorrect input.
How to configure:
Open Page Designer in APEX.
Select the page item you want to validate.
Scroll down to the Validation section and create a validation.
In the Error Message settings, set Display Location to Inline with Field.
Enter an error message, such as:
"Please enter a valid email address."
Save and test the validation.
This method ensures the user can immediately see what needs to be corrected.
2. Inline with Notification (Displayed at the Top of the Page)
The error message appears in a red notification area at the top of the page.
Best for general form errors or when multiple fields need validation.
How to configure:
Open Page Designer in APEX.
Select the validation or process that triggers an error.
In the Error Message settings, set Display Location to Inline with Notification.
Enter a message, such as:
"There are errors in the form. Please correct them before proceeding."Save and run the page.
This method ensures users see all errors at once before submitting the form again.
3. Inline in Notification Area (Displayed in the APEX Messages Area)
Displays errors in a predefined notification area on the page.
Useful for form-wide error handling where messages need to be centralized.
How to configure:
Open Page Designer and navigate to the error-producing component.
Under the Error Message section, select Inline in Notification Area.
Save and test the feature.
This method works well when you want error messages to be consistent with other APEX notifications.
4. Displayed in an Alert Box
Shows the error in a JavaScript popup alert message.
Best for immediate user attention, such as critical validation failures.
How to configure using Dynamic Actions:
In Page Designer, create a Dynamic Action for the button that submits the form.
Set the event to Click and select the button.
Add a True Action and select Execute JavaScript Code.
Enter the following JavaScript code:
alert("Please correct the errors before submitting the form.");
Save and test the form.
This method is useful for critical errors where users must acknowledge the message before continuing.
5. PL/SQL Custom Error Messages (Raise an Exception)
Allows developers to customize error messages in PL/SQL processes.
Best for database-related errors like duplicate entries or missing required data.
Example:
DECLARE
v_count NUMBER;
BEGIN
SELECT COUNT(*) INTO v_count FROM USERS WHERE EMAIL = :P1_EMAIL;
IF v_count > 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'This email is already registered.');
END IF;
END;
When the error is raised, APEX displays the message at the notification area by default.
To make the error display in a different location, wrap the error handling in apex_error.add_error:
BEGIN
IF :P1_AGE < 18 THEN
apex_error.add_error (
p_message => 'Age must be 18 or older.',
p_display_location => apex_error.c_inline_in_notification
);
END IF;
END;
This approach allows developers to control where and how errors are shown in APEX.
Best Practices for Displaying Error Messages
Use Inline with Field for errors related to individual form fields.
Use Inline with Notification for multiple errors in a form.
Use Alert Boxes for urgent or immediate attention.
Use Custom PL/SQL Messages for database errors and business rules.
Provide Clear Error Messages – Instead of "Invalid Input," use "Please enter a valid phone number."
Avoid Overloading Users – Too many messages at once can be confusing. Keep messages concise and relevant.
Oracle APEX provides multiple ways to display error messages, allowing developers to improve usability and user experience. By selecting the appropriate error display location, users can easily identify and correct errors, making applications more intuitive and user-friendly.