I’ve been trying to find out if it is possible to get the id of a report type and everything I’ve found so far points to this doc: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_reporttype.htm

What I don’t get is how to actually access this via apex or whatever other method is available. Anyone know how this works? Thanks in advance.

  • use the apex metadata-api wrapper on github - see the examples and testmethods for usage especially – cropredy Dec 5 '19 at 19:08
  • Are you looking for a Salesforce Id, or for a Developer Name? What are you aiming to do with it? – David Reed Dec 5 '19 at 19:12
  • Salesforce Id, ultimately I’m trying to see if there’s a way to directly link to the page to build a report of a specific report type in lightning. You can do it in classic but it doesn’t work that way in lightning and trying to access it via the id is the last thing I could think of to try to achieve that. I doubt it will work but needed to rule it out. – nicolevy Dec 5 '19 at 19:56

The metadata API isn't necessary for getting report information. In apex, there is the Reports and Dashboards API.


String reportId = [SELECT Id FROM Report WHERE ... ].Id;
Reports.ReportMetadata metadata = Reports.ReportManager.describeReport(reportId).getReportMetadata();
  • Ooh, I should have thought of this; N.B. the ReportMetadata object has methods getLabel() and getType() - OP asked for ReportType Id – cropredy Dec 5 '19 at 19:54
  • 1
    The Type is the unique identifier for a ReportType. – MatthewGTS Dec 5 '19 at 19:55

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.