1

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 Feb 1 '17 at 16:38
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};
    allfilters.addAll(RM.getReportFilters());
    RM.setReportFilters(allfilters);
    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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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