- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:34 AM
Hi folks,
I created a delete job in System Data management => Delete Jobs, but it keeps stopping after a few hours without deleting all the records (apparently due to transaction quotas). I learned that you can use scheduled jobs for this but I cannot see a way to set this delete job that I created to a recurring schedule (can only schedule it to run once in the future).
What would be the best way to accomplish this as a scheduled job?
Thanks,
Ken
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:47 AM
An alternate option will to be use Table cleaners.
How to use Table Cleaner to remove unwanted data - Support and Troubleshooting (servicenow.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:47 AM
An alternate option will to be use Table cleaners.
How to use Table Cleaner to remove unwanted data - Support and Troubleshooting (servicenow.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 06:39 AM
Thanks sonamtiwari,
That was the most stable and quickest way with cascade deletes. It didn't seem to be working quickly but after a few days, the table went from over 20,000 to 30 records.
Best regards,
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 11:14 AM
Probably the best way is to schedule the delete of each record like this:-
var so = new ScheduleOnce();
so.script = "//Your script as a string goes here";
so.schedule();
More details from this great Blog Post
CALL A SERVICENOW SCRIPT ASYNCHRONOUSLY WITH SCHEDULEONCE API
This creates one schedule task and helps when the delete runs several business rules etc.
With any delete job, please test in DEV.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 07:36 AM - edited 02-20-2024 07:39 AM
Hi Gary-NZ,
Thanks for the reply. When you do it this way, does it also cascade delete records in related tables? I have this script:
var gr = new GlideRecord('cmdb_ci_computer');
var strQuery = 'sys_class_name=cmdb_ci_computer^osNOT LIKEserver^osNOT LIKElinux^osNOT LIKEstandard^osNOT LIKEdatacenter^nameNOT LIKEhq';
gr.addEncodedQuery(strQuery);
gr.query();
gr.deleteMultiple();
Thanks,
Ken