One can also define success and error messages declaratively, avoiding having to create a second or third custom action.
Simple Success Message - An even simpler way to show a success notification is by populating the Success Message attribute. This attribute also supports substitution strings, which can be either substituted on the server after the processing is complete, or on the client if you choose so. In this example we are only showing a hardcoded string.
Overridden Success Message - If a static message, or even a message referencing item values isn't enough, you can have even more control by populating the apex_application.g_x01
variable with a custom success message. You can do so in the PL/SQL code block.
Simple Error Message - Similar to the simple success message, you can define a static error message as well. This is what will be shown in case of an unhandled exception. Besides item values, you can also reference the following substitution strings in this message: #SQLCODE#
, #SQLERRM#
and #SQLERRM_TEXT#
.
Overridden Error Message - For even greater control, you can override this message in the PL/SQL code block itself by populating the apex_application.g_x01
variable. Make sure however to still raise the error, so the changes can be rolled back and the error message logged properly. For example:
begin
-- your processing code here
raise_application_error(-20001, 'oh no!');
exception
when others then
apex_application.g_x01 := 'Overridden error message';
raise;
end;