Delete data from table based on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2011 01:02 PM
Hi,
Is there anyway to delete the data from table based on the filter criteria? I have around 8K records to be deleted out of 15K..Manually deleting each one of them would be so laborious.
Any suggestion?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2011 01:16 PM
You could write a background script and delete each record.
http://wiki.service-now.com/index.php?title=GlideRecord#Delete_Methods
Here is an example from that page.
var rec = new GlideRecord('incident');
rec.addQuery('active',false);
rec.query();
while (rec.next()) {
gs.print('Inactive incident ' + rec.number + ' deleted');
rec.deleteRecord();
}
If you are not familiar with how to query, you will want to read up on
http://wiki.service-now.com/index.php?title=GlideRecord#Query_Methods
In "System Definition --> Scripts - -Background" you will be able to run this script to delete a lot of records.
As an FYI ---> Be careful doing this. Make sure your query is correct, as deleting 8000 records can be a big oops if your delete query is not correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2011 01:46 PM
Thanks a lot ...that helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2011 05:33 AM
Here is another good reference for performing queries.
http://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/