Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Aggregate Excel Logger

An Apex utility that demonstrates how to retrieve aggregate-query results in successive batches and emit them as comma-separated debug output for use in a spreadsheet.

The included query identifies duplicate Account records by Name. It is an example intended to be adapted to the data model and reporting requirement of the target Salesforce org.

What it does

  • Runs up to five aggregate-query batches, avoiding the 2,000-row result limit of an individual aggregate query.
  • Uses the maximum CreatedDate returned by each batch as the next cursor.
  • Writes CSV-like output to the Salesforce debug log for copying into Excel or another spreadsheet application.

Project structure

force-app/main/default/classes/AggregateExcelLogger.cls

Use in a Salesforce org

  1. Authorize the target org with the Salesforce CLI.

  2. Deploy the source:

    sf project deploy start --source-dir force-app --target-org <org-alias>
  3. In Execute Anonymous Apex, invoke the utility with an appropriate starting date:

    AggregateExcelLogger.logAggregateQuery(
        DateTime.newInstance(2024, 1, 1, 0, 0, 0)
    );
  4. Open the debug log and copy the comma-separated rows into a spreadsheet.

Important considerations

  • Review and tailor aggregateQuery before deployment; it currently queries Account records and has organization-specific assumptions.
  • This is a one-time diagnostic/export helper, not a general-purpose reporting service.
  • Large result sets can still encounter Apex CPU time or log-size limits. The class comment describes using scheduled executions to split work further.

License

No license is included. By default, the repository is not granted an open-source license; contact the author to request permission for reuse.

About

Apex utility demonstrating iterative aggregate-query logging for spreadsheet export.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages