- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2017 09:16 AM
We are working on a proof of concept in our SandBox instance and deleting all records from our "cmdb_ci_" tables. As there are well over 800 tables, I need a script to list out the tables that are not empty so I will know which ones I need to delete the records from.
I ran the script below as a scheduled job and it deleted over 200k CIs in a few hours, but I don't know if that deleted all records from all cmdb_ci_ tables or if I have more cleanup to do.
How would I create a script to loop through all the cmdb_ci_ tables and list out the ones with records? Thank you for any assistance!
doit("cmdb_ci");
function doit(cmdb_ci) {
var gr = new GlideRecord(cmdb_ci);
gr.deleteMultiple();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2017 09:20 AM
That should do it. If you don't think so, check a sub table like cmdb_ci_hardware and see if there are records there. If you still have leftover data, I can help you build a list of tables. If you don't have to, then let's not go there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2017 11:21 AM
Mike - Great script! Thank you. Mine formatted in 2 very long rows, but I'm playing with that. I appreciate the scripts. See you at K17 hopefully!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 06:32 AM
Great!
Using
var table_array = mod_table_str.split(", ");
So with a space in the split you dont get a preceeding spave in your result array