I want to retrieve more than 2000 records from reports using apex code. I read saleforce report limitation and found 2 different thing.

  1. The API returns up to the first 2,000 report rows.
  2. The number of report rows processed during a synchronous report run count towards the governor limit that restricts the total number of rows retrieved by SOQL queries to 50,000 rows per transaction. This limit is not imposed when reports are run asynchronously.

So that how to implement second point?

  • 2
    For point2 - if request to access reports is done via a batch job, future, queuable, or schedulable class - all these are async transactions
    – cropredy
    Commented Feb 1, 2017 at 16:38

1 Answer 1


you can use a filter on the object id column to exclude the first 2000 results and get the second 2000 until you fetch all the data:

    Reports.ReportResults results = Reports.ReportManager.runReport('00O58000003sea0',true);
    // pars the result to recive the first 2000 ids.
    Reports.ReportFilter RF = new Reports.ReportFilter('ACCOUNT_ID', 'notEqual', ConcatOfReturnIds);
    Reports.ReportMetadata RM = results.getReportMetadata();
    list<Reports.ReportFilter>allfilters = new list<Reports.ReportFilter> {RF};
    results = Reports.ReportManager.runReport('00O58000003sea0', RM,true);
    System.debug(LoggingLevel.INFO,'res: '+results.getFactMap());

for more information see here Glazeforce but don't use the callouts - its use less. regards.

You must log in to answer this question.

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