Hi All,
I've a table named app_file_name where some filenames are stored. In Page 2, Users can upload excel files. I want to show a notification saying “The file is not registered” if filename being uploaded doesn't match any of the filenames stored in the table app_file_name. I've created the following:
create table app_file_name(
id number primary key,
file_name varchar2(4000),
);
ID FILE_NAME
-------------------------------------
1 A.XLSX
2 B.XLSX
3 C.XLSX
PAGE 2
Function and Global Variable Declaration
function show_notification_success(Msg){
apex.message.showPageSuccess(Msg);
$('#t_Alert_Success').attr('style','background-color: green;');
$('.t-Alert-title').attr('style','color: white;font-weight: bold;');
setTimeout(function() {
$('#t_Alert_Success').fadeOut('slow');
}, 5000);
}
function show_notification_error(Msg){
apex.message.showPageSuccess(Msg);
$('#t_Alert_Success').attr('style','background-color: rgb(235, 52, 116);');
$('.t-Alert-title').attr('style','color: white;font-weight: bold;');
setTimeout(function() {
$('#t_Alert_Success').fadeOut('slow');
}, 5000);
}
PAGE ITEMS
Page Item # 1
Identification
Name : P2_CHK
Type : Hidden
Settings
Value Protected : No
Default
Type : Static
Static Value : 0
Page Item # 2
Identification
Name : P2_PX_FILE
Type : File Upload
Display
Display As : Inline File Browse
Storage
Type : Table APEX_APPLICATION_TEMP_FILES
Purge File at : End of Session
Session State
Storage : Per Session (Persistent)
REGION
Identification
Name : Parse Results
Type : Classic Report
Source
Location : Local Database
Type : SQL Query
SQL Query
select line_number,
col001, col002, col003, col004, col005
from apex_application_temp_files f,
table( apex_data_parser.parse(
p_content => f.blob_content,
p_add_headers_row => 'Y',
p_max_rows => 500,
--
p_xlsx_sheet_name => :P2_PX_XLSX_WORKSHEET,
--
p_store_profile_to_collection => 'FILE_PARSER_COLLECTION',
p_file_name => f.filename,
p_skip_rows => 5 ) ) p
where f.name = :P2_PX_FILE
BUTTON
Name : btn_parse
Dynamic Action
Identification
Name : da check valid file
Execution
Event Scope : Static
Type : Immediate
When
Event : Click
Selection Type : Button
Button : btn_parse
True Action # 1
declare
lv_Dummy char(1);
begin
select 'x'
into lv_Dummy
from app_file_name
where upper(file_name) = upper(substr(:P2_PX_FILE,instr(:P2_PX_FILE,'/')+1));
:P2_CHK := 1;
exception
when no_data_found then
:P2_CHK := 2;
end;
Items to Submit : P2_CHK
True Action # 2
Action : Execute JavaScript Code
show_notification_error('This file is not registered.');
Client-side Condition
Type : Item=Value
Item : P2_CHK
Value : 2
Issue : The value for P2_CHK in session is not 2 and the notification 'This file is not registered.’ Is not shown.
Thanks.