Can someone please help me to write SOQL query to get all records for any custom report like "https://xxxxxxx.my.salesforce.com/00O0L000003q8C5" so here "00O0L000003q8C5" is my report id and i need to write SOQL query to pull all records for this report via SOQL. thanks

  • Reports cannot use SOQL queries. You have to use filter conditions in the report to select the desired records. Dec 1, 2019 at 23:29

1 Answer 1


You can't write a SOQL query that returns results for any arbitrary report. Each report is different and would reduce to a different SOQL query.

You can use the Reports and Dashboards API to programmatically execute report runs and extract the resulting data. This API is accessible in Apex or via the REST API.

Alternately, you can analyze each report individually and build a SOQL query that yields the same records as the report run.

You must log in to answer this question.

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