- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:15 AM
Hi folks,
I have a query to return a bunch of computer objects from the cmdb_ci_computer table. I want to use that query in the below script to delete these records from the table:
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();
I am using the background Scripts page at https://<MyDevInstance>.service-now.com/nav_to.do?uri=%2Fsys.scripts.do.
Not sure if this is the best way to do it as I ran the code yesterday and after hanging up my DEV instance for what seemed like the whole day, it only deleted about 1000 records (there are more than 20,000 records to delete).
I am open to any suggestions and I appreciate all the help.
Thanks,
Ken
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:21 AM
Hi there,
Is this just for testing or learning? And is this one of or should this happen frequently?
There are other - saver - methods available. If it's a one off, you might have a look at zero code System Data Management > Delete Jobs.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:21 AM
Hi there,
Is this just for testing or learning? And is this one of or should this happen frequently?
There are other - saver - methods available. If it's a one off, you might have a look at zero code System Data Management > Delete Jobs.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 06:45 AM
I was not aware this existed. This is so much better. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 11:51 AM
Hi folks,
I have an update to this question. I created the delete job 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 schedued job?
Thanks,
Ken