-
Notifications
You must be signed in to change notification settings - Fork 2
Description
While browsing the web, I came across your blog, which features some interesting content about Salesforce development. After reading a few posts, I discovered your GitHub organization and found several useful frameworks. One of my favorites is SOQL Lib and the approach you take to handling selector classes.
Small Selector Classes - The selector class should be small and contains ONLY query base configuration (fields, sharing settings) and very generic methods (byId, byRecordType). Why?
- Huge classes are hard to manage.
- A lot of merge conflicts.
- Problems with methods naming.
Now that you’ve released a new framework (I learned about it through your latest blog post), I took a look and wanted to share an idea to potentially extend it.
What’s the idea?
The framework stores execution results in the AsyncResult__c object, which is very handy. However, I see a potential risk in the long run: record accumulation in this table if not properly managed.
To address this, I’m suggesting the introduction of an automatic cleanup mechanism for old AsyncResult__c records. This feature could be configurable via the existing QueueableJobSettings__mdt Custom Metadata Type, using fields such as:
- A
AutoCleanUpRecords__ccheckbox field to enable or disable the cleanup. - A
CleanUpFrequency__cpicklist field with values like:Daily,Weekly,Monthly,Yearly.
The existing metadata record could act as the global default configuration, so that jobs without a dedicated configuration would inherit this fallback behavior.
As for the actual cleanup process, a scheduled job (e.g., AutoAsyncResultCleanupScheduler) could run daily and:
- Read all active job configurations.
- Determine which records are eligible for deletion based on the configured frequency.
- Launch one or more async jobs to delete the identified records.
This would help ensure the framework remains sustainable over time by avoiding uncontrolled data growth. , while keeping the implementation transparent and maintainable for teams adopting the framework.
Let me know what you think!