0

I am trying to find reports that uses a certain field as one of its filters. The below is where I got to so far. I know there is ReportMetadata.getReportFilters method, but not sure how to use it here

List <Report> reportList = [SELECT Id,DeveloperName FROM Report];
for(Report r: reportList) {
    String reportId = (String)r.get('Id');
    Reports.ReportResults results = Reports.ReportManager.runReport(reportId);
    Reports.ReportMetadata rm = results.getReportMetadata();
    System.debug('Name: ' + rm.getName());
    System.debug('ID: ' + rm.getId());
    System.debug('Developer name: ' + rm.getDeveloperName());
}

This is what I get when I run this anonymous window- enter image description here

1 Answer 1

0

reports.ReportManager.runReport(reportId) method is not working for Multiblock report Format. I hope there should be some report in your org which belongs to this category because of which it is failing.

I have tried the same snippet of code by putting the filters on the query which gave me the expected results as below.

    List <Report> reportList = [SELECT Id,DeveloperName FROM Report where Format='Tabular' or Format='Summary'];
    for(Report r: reportList) {
        String reportId = (String)r.get('Id');
        Reports.ReportResults results = Reports.ReportManager.runReport(reportId);
        Reports.ReportMetadata rm = results.getReportMetadata();
       List<Reports.ReportFilter> rptFilters = rm.getReportFilters();
   system.debug('filters'+rptFilters);

    }
2
  • Thanks @SaiPraveen, actually I was trying to list all the filters inside of each report. The code I provided was where I got so far. Could you update your answer to have the code list the filters for each report as well?
    – sumchans
    Aug 30, 2022 at 3:40
  • Updated the code for the same Aug 30, 2022 at 3:46

You must log in to answer this question.

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