How to show dynamic error message with field in Oracle apex
Sometimes we need to show specific error message highlighted with related field item. Below example showing if the user status is inactive during login it will show ‘Inactive User’ instead of showing ‘Invalid login’:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
declare v_user_status char(1):= 'N'; begin select STATUS into v_user_status from USER_MASTER where user_name = :P101_USERNAME; if v_user_status = 'Y' then return true; else apex_error.add_error ( p_message => 'Inactive User!', p_display_location => apex_error.c_inline_with_field, p_page_item_name => 'P101_USERNAME'); end if; |
Note: Make sure you did not put ‘:’ before Page Item to assign value of parameter p_page_item_name You can show your message also dynamic, in that case put your dyanamic message in a variable and place that variable name in the p_message => section.
To show both field and notification use
1 |
apex_error.c_inline_with_field_and_notif |
To show on error page use apex_error.c_on_error_page
To show only in notification use below:
1 2 3 |
apex_error.add_error ( p_message => 'Inactive User!', p_display_location => apex_error.c_inline_in_notification ); |
Thank You