Jump to content

Create a button in an HTML DataPage that downloads the reports of each embedded Report DataPages all at once

Recommended Posts


So I have an HTML DataPage wherein I embedded multiple Report DataPages as iFrames. Would it be possible for me to have a button in the HTML DataPage that activates all the Download Data link for each of the Report DataPages so that all of them are 'clicked' all at once then generates the documents all at once? This way I wouldnt have to download them individually.

Link to comment
Share on other sites

Hi, you could achieve this with JavaScript. You create a function for your button's onClick event. So in your body, you create the button like so:


<button  onclick="myFunction()">Print all</button>


Then for the actual script:


function myFunction() {
  const iframez = document.getElementsByTagName("iframe");

Array.from(iframez).forEach(function(elt, i){
var downloadData= elt.contentWindow.document.getElementsByClassName("cbResultSetDownloadLink");


What this does is it collates all of the "Download Data" link on each of the Report DataPage and then 'clicks' each of them, therefore downloading the report. If your Report DataPage allows download of only one specific type of file (i.e. only Excel), it automatically downloads that file. But if you enable multiple file types (PDF, Excel), then you will see the dropdown which allows you to choose the file type, then proceeds with the download.


Note that you would have to wait for all the iFrames to load to be able to download all of their reports.

Link to comment
Share on other sites

In additional to my last response, you can also add a code that enables the button ONLY when all the iFrames have loaded.

On your button, add an ID and add the 'disabled' attribute:

<button id="printall" disabled onclick="myFunction()">Print all</button>


By default, the button will then be disabled. Then, at the beginning of your script, add:


window.addEventListener("load", function(){
document.getElementById('printall').disabled = false;


What this does is, once the page has loaded completely (including the iFrames), the button will then be enabled.

This is optional. Interface-wise, there's no harm when a user clicks on the Print All button even though the iFrames have not loaded completely, but you could apply this so that there won't be a fuss about a report not being downloaded, or the button not working, when in reality, the iFrames haven't loaded yet, hence why the report is not generated.


Hopefully that makes sense!



Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...