I have creating my first simple plugin. The idea is to have button in a page, on clicking of which an interactive report region will be reset, instead of going through "Actions menu" of IR.
Plugin is dynamic action on button click which takes input of Static ID of the report region. Its working fine, just the its getting fired on page load too. I have set "Fire on initialization" in dynamic action to off. But still its firing.
Following is the export of the plugin.If anyone could point out why its firing on page load?
prompt --application/set_environment
set define off verify off feedback off
whenever sqlerror exit sql.sqlcode rollback
--------------------------------------------------------------------------------
--
-- Oracle APEX export file
--
-- You should run this script using a SQL client connected to the database as
-- the owner (parsing schema) of the application or as a database user with the
-- APEX_ADMINISTRATOR_ROLE role.
--
-- This export file has been automatically generated. Modifying this file is not
-- supported by Oracle and can lead to unexpected application and/or instance
-- behavior now or in the future.
--
-- NOTE: Calls to apex_application_install override the defaults below.
--
--------------------------------------------------------------------------------
begin
wwv_flow_imp.import_begin (
p_version_yyyy_mm_dd=>'2024.11.30'
,p_release=>'24.2.9'
,p_default_workspace_id=>94893994166627935
,p_default_application_id=>888
,p_default_id_offset=>108018004803313811
,p_default_owner=>'APEX_NTXD'
);
end;
/
begin
-- replace components
wwv_flow_imp.g_mode := 'REPLACE';
end;
/
prompt --application/shared_components/plugins/dynamic_action/reset_report_button
begin
wwv_flow_imp_shared.create_plugin(
p_id=>wwv_flow_imp.id(118875325050137132)
,p_plugin_type=>'DYNAMIC ACTION'
,p_name=>'RESET.REPORT.BUTTON'
,p_display_name=>'Reset report button plugin'
,p_category=>'EXECUTE'
,p_javascript_file_urls=>'#PLUGIN_FILES#reset-report-button-plugin#MIN#.js'
,p_plsql_code=>wwv_flow_string.join(wwv_flow_t_varchar2(
'FUNCTION plugin_reset_report(',
' p_dynamic_action IN apex_plugin.t_dynamic_action,',
' p_plugin IN apex_plugin.t_plugin',
')',
' RETURN apex_plugin.t_dynamic_action_render_result',
'IS',
' l_result apex_plugin.t_dynamic_action_render_result;',
' v_report_static_id varchar2(100);',
'BEGIN',
' -- Enable debug mode',
' IF APEX_APPLICATION.g_debug',
' THEN',
' apex_plugin_util.debug_dynamic_action( p_plugin => p_plugin, p_dynamic_action => p_dynamic_action );',
' END IF;',
' v_report_static_id := apex_escape.html(p_dynamic_action.attribute_01 );',
' -- cf_reset_report is javascript function define in javascript file of this plugin',
' l_result.javascript_function := ''cf_reset_report("'' || v_report_static_id || ''")'';',
' RETURN l_result;',
'END plugin_reset_report;'))
,p_api_version=>1
,p_render_function=>'plugin_reset_report'
,p_standard_attributes=>'REGION:REQUIRED'
,p_substitute_attributes=>true
,p_version_scn=>92810046976
,p_subscribe_plugin_settings=>true
,p_help_text=>'This plugin is used to create trigger the "reset" of interactive report in oracle apex. Instead of clicking on Actions Menu, then, Report, then Reset, we can simply create a button on page which will reset the report directly.'
,p_version_identifier=>'1.0'
,p_plugin_comment=>'Created on 12/11/2025 - Arif Sher Khan - Version 1.0'
,p_files_version=>23
);
wwv_flow_imp_shared.create_plugin_attribute(
p_id=>wwv_flow_imp.id(118877950763191083)
,p_plugin_id=>wwv_flow_imp.id(118875325050137132)
,p_attribute_scope=>'COMPONENT'
,p_attribute_sequence=>1
,p_display_sequence=>10
,p_prompt=>'Report region Static ID'
,p_attribute_type=>'TEXT'
,p_is_required=>true
,p_is_translatable=>false
,p_examples=>'If you have given Static ID as my-ir, then give my-ir in this too.'
,p_help_text=>'Provide the Static ID of the region which you want to reset on the click of a button. No need to add #. You must give the static ID as given in the region.'
);
end;
/
begin
wwv_flow_imp.g_varchar2_table := wwv_flow_imp.empty_varchar2_table;
wwv_flow_imp.g_varchar2_table(1) := '66756E6374696F6E2063665F72657365745F7265706F727428705F7265706F72745F696429207B0D0A20202020747279207B0D0A202020202020202076617220765F7265706F72745F6964203D20222322202B20705F7265706F72745F6964202B20225F';
wwv_flow_imp.g_varchar2_table(2) := '616374696F6E735F6D656E75223B0D0A2020202020202020202428765F7265706F72745F6964292E6D656E75282266696E64222C20226972526573657422292E616374696F6E28293B0D0A202020207D20636174636820286572726F7229207B0D0A2020';
wwv_flow_imp.g_varchar2_table(3) := '20202020202076617220765F6572726F725F6D657373616765203D20224572726F7220657865637574696E67207265736574207265706F727420627574746F6E20706C7567696E2E20537461746963204944206F662074686520726567696F6E2069733A';
wwv_flow_imp.g_varchar2_table(4) := '22202B20705F7265706F72745F6964202B222E220D0A2020202020202020636F6E736F6C652E6C6F6728765F6572726F725F6D6573736167652C206572726F72293B0D0A20202020202020207468726F77206E6577204572726F72282246726F6D206170';
wwv_flow_imp.g_varchar2_table(5) := '657820706C7567696E202D20436865636B20636F6E736F6C65206D65737361676573206265666F7265207468697322293B0D0A202020207D0D0A7D0D0A';
end;
/
begin
wwv_flow_imp_shared.create_plugin_file(
p_id=>wwv_flow_imp.id(118876397447154355)
,p_plugin_id=>wwv_flow_imp.id(118875325050137132)
,p_file_name=>'reset-report-button-plugin.js'
,p_mime_type=>'text/javascript'
,p_file_charset=>'utf-8'
,p_file_content=>wwv_flow_imp.varchar2_to_blob(wwv_flow_imp.g_varchar2_table)
);
end;
/
begin
wwv_flow_imp.g_varchar2_table := wwv_flow_imp.empty_varchar2_table;
wwv_flow_imp.g_varchar2_table(1) := '66756E6374696F6E2063665F72657365745F7265706F72742865297B7472797B24282223222B652B225F616374696F6E735F6D656E7522292E6D656E75282266696E64222C226972526573657422292E616374696F6E28297D6361746368286F297B7661';
wwv_flow_imp.g_varchar2_table(2) := '7220723D224572726F7220657865637574696E67207265736574207265706F727420627574746F6E20706C7567696E2E20537461746963204944206F662074686520726567696F6E2069733A222B652B222E223B7468726F7720636F6E736F6C652E6C6F';
wwv_flow_imp.g_varchar2_table(3) := '6728722C6F292C6E6577204572726F72282246726F6D206170657820706C7567696E202D20436865636B20636F6E736F6C65206D65737361676573206265666F7265207468697322297D7D';
end;
/
begin
wwv_flow_imp_shared.create_plugin_file(
p_id=>wwv_flow_imp.id(118891221716303072)
,p_plugin_id=>wwv_flow_imp.id(118875325050137132)
,p_file_name=>'reset-report-button-plugin.min.js'
,p_mime_type=>'text/javascript'
,p_file_charset=>'utf-8'
,p_file_content=>wwv_flow_imp.varchar2_to_blob(wwv_flow_imp.g_varchar2_table)
);
end;
/
prompt --application/end_environment
begin
wwv_flow_imp.import_end(p_auto_install_sup_obj => nvl(wwv_flow_application_install.get_auto_install_sup_obj, false)
);
commit;
end;
/
set verify on feedback on define on
prompt ...done
I'm using Apex 24.2, Oracle 23ai
You can use like this:
l_result.javascript_function := 'cf_reset_report';
l_result.attribute_01 := v_report_static_id;
return l_result;
Then in your JavaScript:
let cf_reset_report = function()
{
let reportStaticId = this.action.attribute01;
//...
}