Fidgeting with the APEX Interactive Report Widget

Fidgeting with the APEX Interactive Report Widget

I recently had a request to "make it easier" to get to the default saved interactive reports. The default user interface doesn't make it obvious that there are saved report alternatives. I started with the APEX javascript APIs to see if I could find a supported way to do this. Unfortunately, I didn't see what I needed in the documentation. The next step was Google. I found John Snyders's blog post on a similar topic:

https://hardlikesoftware.com/weblog/2015/05/12/apex-5-0-interactive-report-customization/

The short answer is that there is not a supported way to do it. John discusses how he does something similar in an unsupported, but probably safe way. If it's good enough for John, it's going to have to be good enough for me.

  1. The javascript to set the saved report is as follows:
    $('#affinityGroupsIR_saved_reports').val('93483432038944040');$('#affinityGroupsIR_saved_reports').trigger('change');
    - affinityGroupsIR is either the region static ID (or the region ID if a static ID has not been defined.
    - The long number (93483432038944040) is the underlying ID of the report. That takes us to step 2.

  2. You need a way to get that long number, and ideally, also find a way to get the list of primary and alternative default reports. You could hard-code it, but why, when it is so easily available? I chose to implement this as a dynamic list--which means you must have a very specific query to meet the structure of a dynamic list.

Below is the query for the dynamic list:

select 1 the_level, 
       case when pir.report_type = 'PRIMARY_DEFAULT' then 'All Affinity Groups' 
         else pir.report_name 
         end label, 
       'javascript:$(''#' ||nvl(pr.STATIC_ID, pr.region_id)|| '_saved_reports'').val('''|| pir.report_id ||''');'
       || '$(''#' || nvl(pr.STATIC_ID, pr.region_id) ||'_saved_reports'').trigger(''change'');' target, 
       null             is_current_list_entry,
       null             image, 
       null             image_attribute,
       null             image_alt_attribute,
       't1'             attribute1,
         't2'               attribute2,
      'tab-report-item' attribute3,
      'tab-report-link' attribute4,
       null             attribute5,
       null             attribute6,
       null             attribute7,
       null             attribute8,
       null             attribute9,
       null            attribute10
from APEX_APPLICATION_PAGE_IR_RPT pir
join apex_application_page_regions pr on pr.region_id = pir.region_id
  where pir.application_id = :APP_ID
    and pir.page_id = :APP_PAGE_ID
    and pir.report_type in ('PRIMARY_DEFAULT','ALTERNATIVE_DEFAULT')
    and pr.static_id = 'affinityGroupsIR'
order by pir.report_type desc, pir.DISPLAY_SEQUENCE, pir.report_name

I also chose to have my list look like tabs. That is what attribute3 and attribute4 are for. I chose a region type of "List" and a region template of "Tabs Container" and region attributes > list template of "Tabs".