How can i get the selected saved reports ID from an Interactive Grid? In Oracle APEX

402 views Asked by At

So basically i would like to have a custom printing process from my IG, that prints data based on the selected Saved Report from the built in report list. (no, the built in printing method, does not cut it)

So im using this built in process for printing:

apex_region.export_data (
     p_format       => 'csv',
     p_page_id      => :APP_PAGE_ID,
     p_region_id    => v_region_id,
     p_component_id => ?????);

The problem is that i cant get the component id to print the data, if i get rid of the component parameter it works fine, but it only prints the primary riport.

I tried to get the value via dynamic action JS code, but im not expert in JS so i failed badly.

1

There are 1 answers

0
Peter On

You can get the component id from the APEX view apex_appl_page_ig_rpts.

A simple example:

DECLARE
    l_export    apex_data_export.t_export;
    l_region_id NUMBER;
    l_report_id NUMBER;
    l_app_id    NUMBER := 101;
    l_page_id   NUMBER := 1410;
BEGIN
    apex_session.create_session(p_app_id => l_app_id, p_page_id => l_page_id, p_username => 'ME');

    --apex_util.set_session_state('MY_ITEM', 33);
    SELECT region_id
    INTO l_region_id
    FROM apex_application_page_regions
    WHERE application_id = l_app_id
    AND page_id = l_page_id
    AND static_id = 'MY_STATIC_REPORT_ID';

    SELECT report_id
    INTO l_report_id
    FROM apex_appl_page_ig_rpts
    WHERE application_id = l_app_id
    AND page_id = l_page_id;
    --AND name = 'Test'

    l_export := apex_region.export_data(p_format => apex_data_export.c_format_csv, 
                                        p_page_id => l_app_id, 
                                        p_component_id => l_report_id, 
                                        p_as_clob => TRUE,
                                        p_region_id => l_region_id);

    dbms_output.put_line(l_export.content_clob);
END;
/