Tuesday, March 24, 2009

APEX Interactive Report - Download with One Click

We've been working with Interactive Reports (IR) over the past few months and have had to do a lot of customization to meet some of our customers requirements. Over the next few weeks my posts will be focused on these customizations.

To start, here's an example of how to modify the download button in IRs. Just some background on this, we're only supporting CSV downloads now. When the clients would download IRs they would have to click the "Download" link then click on the "CSV" button.

We found this extra step unnecessary so here's a way on how to do it in one step so that it will download as soon as they click "Download". We used jQuery to help out a bit. Here's a working example.

$(document).ready(function() {
$('.dhtmlSubMenuN[title="Download"]').attr('href','f?p=' + $v('pFlowId') + ':' + $v('pFlowStepId') + ':' + $v('pInstance') + ':CSV:');

Here's a detailed summary of how it works: If you scroll over the "CSV" download button you'll noticed that it looks something like : "f?p=102:3:207941080701500:CSV:". If we break that down it's really: "f?p=:::CSV:". In Javascript you can reference each as follows:

APP_ID = $v('pFlowId');
APP_PAGE_ID = $v('pFlowStepId');
SESSION_ID = $v('pInstance');

Now to alter the "Download" link from the interactive report menu we use jQuery to identify the link: "$('.dhtmlSubMenuN[title="Download"]')" and then use the attr function to set with the new URL.


  1. Hi,
    Thanks a lot for posting this.
    Can you please let us know where exactly we should be placing the jQuery and how is it getting invoked?


  2. Hi,
    Thanks a lot for posting this.
    Can you please let us know where exactly we should be placing the $(document).ready(function() {
    $('.dhtmlSubMenuN[title="Download"]').attr('href','f?p=' + $v('pFlowId') + ':' + $v('pFlowStepId') + ':' + $v('pInstance') + ':CSV:');

  3. If you're using APEX 4.0, create an On Page Load dynamic action of type JavaScript. You can paste the code into the Code section.


  4. Good stuff!
    Thanks so much!! :)

  5. Hi Martin:

    This works great when the page is first loaded, but if the report is changed dynamically (e.g., by doing Actions > Select Columns) it reverts back to displaying the Apex download menu. See page 2 (Customers) of:


    User ID: DEMO
    Password: demo

    Can you let us know how to fix this?


    1. Hi Gerald,

      You can create an After Refresh Dynamic Action on the report and run the JS to hide the CSV download button.