function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HDoshi.ax1738HDoshi.ax1738 

Retrieve Report's ReportType value

Hello,
I need to retrieve reports available in the salesforce org.
I am able to retrieve all the reports (using SOQL query) with its folder name but I am not able to retrieve "Report Type" of the report. I checked there is [Report Type] object but no field in [Report] object to connect with [Report Type] object.
How can I retrieve [Report Type] ?
Rufus RodenRufus Roden
Not sure if this is possible in SOQL.
You can do it via Apex though:
// Find a sample report id
Report rpt = [select id from report limit 1];
Id reportId = rpt.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 localized display name of the report type.
System.debug(rt.getLabel());

// Output the nique identifier of the report type.
System.debug(rt.getType());