How to delete records between a start and end date using sys_auto_flush?

TEJAS
Tera Contributor

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


5 REPLIES 5

Aditya Kumar6
Tera Contributor

In the particular scenario it will be easier to use the data management service:

 

Category Data Management Jobs sys_auto_flush Table

TypeConfigurable scheduled jobSystem-level buffering mechanism
User AccessAdmin-configured via UIMostly hidden, platform-managed
Example Tablessys_cleanup, sys_archive_schedulesys_auto_flush, affects sys_journal_field
GoalManage system data retention and storageImprove performance of journal field updates
Common UseDelete logs, archive incidentsCache 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