+ Start a Discussion
ArunaAruna 

reports.MetadataException: Can't run the report because it doesn't have any columns selected. Be sure to add fields as columns to the report through the user interface.

Hello,

I am trying to get the report information  like  what are the filters on the report by using  report metadata.
But I am getting below error

reports.MetadataException: Can't run the report because it doesn't have any columns selected. Be sure to add fields as columns to the report through the user interface.

below is my code 
List <Report> reportList = [SELECT Id,Name,DeveloperName FROM Report ORDER BY Name DESC];
     for(Integer i=0;i<reportList.size();i++){
         
         String reportId = (String)reportList.get(i).get('Id');
         String Name = (String)reportList.get(i).get('Name');
         
         Reports.ReportResults results = Reports.ReportManager.runReport(reportId);
         Reports.ReportMetadata rm = results.getReportMetadata();
         
        system.debug('---Name---'+Name);
         system.debug('---reportId---'+reportId);
         system.debug('---results'+results);
         system.debug('---rm'+rm);
          
         for(Reports.ReportFilter rf : rm.getreportFilters()){
             if(rf!=null){
                 system.debug('---col name---'+rf.getcolumn());
                 system.debug('---col value---'+rf.getValue());
             }
         }
 
Please let me know how do overcome with this error.