background script to close all incidents.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 08:46 PM
What should I write in background script to close all incidents or delete all incidents
Labels:
- Labels:
-
Incident Management
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 09:45 PM
closeStaleIncidents();
function closeStaleIncidents() {
var closeState = 7;
var gr = new GlideRecord('incident');
gr.query();
gr.setValue('state', closeState);
gr.updateMultiple();
//Use gr.deleteMultiple(); to delete all Incidents
}
Reference:
Pro Tip: Use updateMultiple() for Maximum Efficiency! by Tim Woodruff

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2018 08:06 AM
Hi Akshay,
Please mark my answer as correct so that others can benefit from similar question.
Regards,
Sachin