0

As I stated in the headline, I want to be able to run the report and see if It is returning rows or not. (empty or has data)

The background is that I am exporting reports data. So I need to know when the report is empty, in order to avoid the export of the empty report because I end up with HTML data in the report instead of rows. I want to avoid that and make it more user friendly.

I investigated a below result from Reports.ReportResults object and did not found anything that could be used as a solid flag for this case.

Reports.ReportResults results = Reports.ReportManager.runReport(reportId, true);
System.debug(results);

Any help or idea would be appreciated.

3

1 Answer 1

0

// Get the fact map from the report results - assuming it is a tabular report Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)results.getFactMap().get('T!T');

system.debug('results '+factDetails);

//get row size integer rowCount = factDetails.getRows().size();

// Get the field value from the first data cell of the first row of the report Reports.ReportDetailRow detailRow = factDetails.getRows()[0];

System.debug(detailRow.getDataCells()[0].getLabel());

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .