How to delete records between a start and end date using sys_auto_flush?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2025 03:08 AM
Hi everyone,
I’m leveraging the sys_auto_flush table to automate record deletions in a scoped application. For most scenarios, I calculate the age field based on standard timeframes (like "last X days"), and everything works as expected.
However, I’m trying to support a use case where users define a custom date range with a start and end date.
To implement this, I currently calculate age as the difference (in seconds) between the current time and the end date, with the assumption that sys_auto_flush will delete records older than that end date.
This works in deleting records older than the end date, but what I really need is to delete records only between the start and end dates — not beyond.
Question:
Is it possible to configure sys_auto_flush to target only records within a specific date range (start to end).
Appreciate any best practices or suggestions others have used for similar requirements!
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2025 05:30 AM
In the particular scenario it will be easier to use the data management service:
Category Data Management Jobs sys_auto_flush Table
Type | Configurable scheduled job | System-level buffering mechanism |
User Access | Admin-configured via UI | Mostly hidden, platform-managed |
Example Tables | sys_cleanup, sys_archive_schedule | sys_auto_flush, affects sys_journal_field |
Goal | Manage system data retention and storage | Improve performance of journal field updates |
Common Use | Delete logs, archive incidents | Cache and flush comments, work notes |
You can also look into scheduling them refer : https://www.servicenow.com/community/developer-articles/how-scheduling-data-management-delete-jobs-w...
Please mark this answer helpful if it answers your query