Unable to Delete Assets and Computers via Fix Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 02:23 PM
HI, I'm attempting to delete all of our CI's that were brought in via our SCCM integration, I've tried the following code but it does not delete all the records.
var ci = new GlideRecord('cmdb_ci');
ci.addEncodedQuery('discovery_source=SG-SCCM^sys_class_name=cmdb_ci_computer');
ci.query();
while(ci.next()){
ci.deleteMultiple();
}
var computer = new GlideRecord('cmdb_ci_computer');
computer.addEncodedQuery('discovery_source=SG-SCCM');
computer.query();
while(computer.next()){
computer.deleteMultiple();
}
var hardware = new GlideRecord('alm_hardware');
hardware.addEncodedQuery('ci.discovery_source=SG-SCCM');
hardware.query();
while(hardware.next()){
hardware.deleteMultiple();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 06:19 AM
Hello @AshishKM ,
// delete all record from alm_hardware table
var hardware = new GlideRecord('alm_hardware'); hardware.addEncodedQuery('ci.discovery_source=SG-SCCM');
hardware.query();
hardware.deleteMultiple();
We used above script to delete data but it only deletes 100 records at a time and stops execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 06:54 PM
Hi @syed_but_not without scripting we can use Delete jobs.
I'm sharing the link below with an example.
Update or Delete Bulk Records without Scripting - ServiceNow Community
Mark this Helpful !!. If this Helps you to understand. This will help both the community and me.