0

I have a list of report types and I need to find out which reports in my org are using any of those report types. Is there a way to do so instead of manually visiting each report and checking its report type? There are about 14500 reports in my org and I would rather not manually check each one.

Is there a way to query reports based on the report type? I am able to query report names and id's and based on the report id, I can get the report type through the reportMetadata but that isn't ideal since I want to input the report type and fetch reports based on that value.

This is the code I am using for the former.

        List<Report> rpt = [select id,name from report limit 10];
    
        for(Integer i=0; i<10; i++) {
            Id reportId = rpt[i].id;
            
            // Get the report description
            Reports.ReportDescribeResult reportDescription = Reports.ReportManager.describeReport(reportId);
            
            // Get the metadata
            Reports.ReportMetadata reportMetadata = reportDescription.getReportMetadata();
            
            // Get the report type
            Reports.ReportType rt = reportMetadata.getReportType();
                
            // Output the report's name.
            System.debug(i +' Report Name: '+ rpt[i].name);
            
            // Output the localized display name of the report type.
            System.debug(i +' Report Type Name: '+ rt.getLabel());
        }
4
  • Are you looking to build automation on top of the results of such data or is this for manual review?
    – TSmith
    Apr 29, 2021 at 15:37
  • @TSmith Just for manual review, need to look into those reports and see which fields from the report types are not being utilized by them.
    – Reaper1883
    Apr 29, 2021 at 15:40
  • How about a Report of Reports, would that suffice? I can answer below on how to build that out if you think it would be a solution.
    – TSmith
    Apr 29, 2021 at 15:42
  • @TSmith Hmm, I am not sure if that would work but it is definitely worth a try. Please let me know how I can build that and thanks.
    – Reaper1883
    Apr 29, 2021 at 15:46

1 Answer 1

4

This is not supported through Apex currently (see Idea) but I can offer a declarative solution by creating a report of reports :)

Create a custom Report Type with Primary Object of Reports. This will allow you to build a summary view of all Reports and their Report Type or you can group by Report Type.

enter image description here

enter image description here

1
  • 1
    Thanks @TSmith for the report of reports idea. Tried it just before you posted the answer. Works as expected and strange that we can't query the Report object directly based on the report types.
    – Reaper1883
    Apr 29, 2021 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.