Christoph's 2 Cents

A Backup for My Brain!

Oracle Developement

Use jQuery to check if a report returned rows in Apex

In order to conditionally hide/show a button, I needed to know whether a particular report on a page returned any rows.

This can easily be done with a line of jQuery, which differs between classic and interactive reports:

  1. Make sure to give your report a static ID. In this example it is emp.
  2. Classic Report:  If data is returned there will be a div with an id that prepends ‘report_’ to the report static id. Check the length of that div to find out if it exists. If it doesn’t, the length will be zero, meaning no rows were returned.
    1. $('#report_emp').length
  3. Interactive Report:
    1. $('#emp').find('div[id="apexir_DATA_PANEL"] table').length
    2. Here, if the length comes back as one, the report returned no rows.

Thanks to @rimblas for a correction.