Deletion of Mass CI in CMDB

ShiningStar1
Tera Contributor

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.

1 REPLY 1

Runjay Patel
Giga Sage

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

-------------------------------------------------------------------------