Skip to main content

Command Palette

Search for a command to run...

Showing Success and Error Messages in Oracle APEX Made Easy

Updated
2 min read
Showing Success and Error Messages in Oracle APEX Made Easy

Using PL/SQL

Soft validation error - Does not crash page, adds to stack, for business rule validation failure message. (for more check apex_error).

apex_error.add_error (
    p_message          => 'Username should not contain numbers',
    p_display_location => apex_error.c_inline_in_notification,
    p_page_item_name   => 'P3_USERNAME'
);

Hard Stop Exception - Crashes execution immediately, only for critical technical errors

-- Range must be between -20999 and -20000
RAISE_APPLICATION_ERROR(-20001, 'Critical Error: Authorization Failed');

Success Message after page submit - To be used in page processes, Display on next page load.

APEX_APPLICATION.G_PRINT_SUCCESS_MESSAGE := 'Record Saved Successfully.';

Better way to show static success message after page submit is to put it in the success message attribute of the page process. If you want to make success message dynamic (e.g. “Row ID - XXXX processed!”), return the row_id value in a hidden page item (let PX_ROW_ID) and define the success message attribute value like - Row ID - &PX_ROW_ID. processed!.

Check example use here.

Using apex JavaScript API apex.message.

Show and clear errors using JS

apex.message.showErrors([{
    type:       "error",
    location:   [ "page", "inline" ],
    pageItem:   "P10_ITEM_NAME",
    message:    "Value must be greater than 0",
    unsafe:     false
}]);
apex.message.clearErrors();

Show and clear Success messages using JS

apex.message.showPageSuccess("Process Completed Successfully!");

// auto dissmiss duration can be set by putting below code into "Execute When Page Loads" section of page header.
apex.message.setDismissPreferences({
    dismissPageSuccess: true,
    dismissPageSuccessDuration: 3000 // Duration in milliseconds (3 seconds)
});

Referances - apex.message