Mass Deleting CIs, need to suppress that they were deleted on the User Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 02:32 PM
I need to delete about 18,000 CIs that were created when an Intune import went wild, but I don't want them to enter a note on the Activity feed of the users it just causes noise, and some users have 185 Cis that need to be deleted.
You can see in this screenshot I deleted a Camera and a Dock from the sys_cmdb_peripheral table, and this caused 6 entries for those two items on this user's record.
I tried adding the attribute "No audit delete" to both the sys_user table and the sys_cmdb_peripheral table, but that didnt work...
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 03:41 PM
Hi @Donovan B ,
Did you try using gr.setWorkflow(false) and gr.autoSysFields(false) ?
If not then please use these in your fix script or background script so that you have the below things covered:
gr.setWorkFlow(false) - helps in doing data changes without triggering any underlying business rules.
gr.autoSysFields(false) - helps in doing data changes without updating the system fields.
Please mark this answer as "Helpful" if this helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 05:03 PM
thanks for the idea, I tried that and it did suppress one of the items, the expense item, but it still adds the 2 CI deletions (one is Unknown)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 05:45 PM
Hi @Donovan B ,
Can you please provide the script so that I can check and revert back?
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 11:00 PM
var duplicate = new GlideRecord('cmdb_ci_peripheral');
duplicate.addQuery('type', '=', 'Dock');
//duplicate.addNullQuery('serial_number'); // Add a query to check for blank serial numbers
duplicate.setLimit(10); // Set a limit of records to be processed
duplicate.query();
duplicate.setWorkflow(false);
duplicate.autoSysFields(false);
while (duplicate.next()) {
duplicate.deleteRecord();
}
Thanks for the help!
Donovan