Deletion of Mass CI in CMDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 02:14 AM
Hello All,
Got a requirement for mass deletion of CI with number 42 k CIs.Please help us with a script to delete this CIs and the condition is discovery source is empty.Anyone please reply as it a bit urgent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 02:27 AM
Hi @ShiningStar1 ,
You can use below script in either fix script or in background script.
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addEncodedQuery('discovery_source=');
ciGr.deleteMultiple();
Also you can refer this blog for best way of deleting record in servicenow: https://servicenowwithrunjay.com/delete-multiple-records-using-background-scripts/
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------