I want to delete five active incident records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:04 PM
I want to delete five active incident records on incident table.
- Labels:
-
Incident Management
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:09 PM
Hi, deletion of records is not recommended, but it is a simple UI action from the list view of the table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:12 PM
Hi,
You can use below code from background script to delete the records.
var incGR = new GlideRecord('incident');
incGR.addQuery('sys_id','IN',<sys_ids of the records>);
incGR.query();
if(incGR.next()){
incGR.deleteMultiple();
}
But it is not recommended to delete any records, you can deactivate the records.
Regards,
Vaibhav Dane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:16 PM
Hii Vaibhav,
I want to delete only five active incident records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 10:16 PM
Hi, If this any 5 Random active record then you can use below code also
var gr=new GlideRecord("incident");
gr.addEncodedQuery("active=true");
gr.setLimit(5);
gr.query();
gs.info(gr.getRowCount());
gr.deleteMultiple();