Delete Records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 04:53 AM
Hi All,
I have created update set and created table which extends CMDB.
I have created the records in the new table.
I have backouted the update set. Table is deleted and everything related to that like business rules were gone.
But the records which I have created in the new table are still present under the cmdb table with Class as label.
The problem here is the records which I have created in new table are not getting deleted from the cmdb table.
Please anyone help me, I tried to delete the records from the background script but didnt worked.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 05:05 AM
It sounds like your table was deleted, but the table relationship may have gotten disrupted somewhere. There's always going to be a sys_id at the parent class to join with the rest of the record at the child class.
How many records are there? If it is less than 100, I'd just use the list to check them and delete them.
If it's lots of records then see if you can filter the cmdb table list to just the records you want to delete and copy the query in to a script you have in scripts background. This should help if you haven't don that before.
Video: Scripting Complex Queries Quickly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 05:08 AM
Hi chuck,
I tried with background scripts, and also with the checkbox, they are not deleting. There are less than 1000 records
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 05:13 AM
If this is your corporate instance, then I recommend reaching out to support. They may have to do something at the database level.
HI Service Portal - ServiceNow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 07:45 AM
Please use below code to delete record and it's references in corresponding tables.
//Find all non-active incident records and delete them
var md = new Packages.com.glide.db.MultipleDelete('incident');
md.addQuery('active', false);
md.setAllowCascadeDelete(); // optional: Allow cascading to records in other tables related to records being deleted
md.execute();
Regards.
Sachin