background script to close all incidents.

- 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:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 08:54 PM
Please use below background script to close all incidents.
var inc = new GlideRecord('incident');
inc.query();
while(inc.next()){
inc.state = 7;
inc.update();
}
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 09:28 PM
Hi
Try this:
var gr = new GlideRecord("incident");
gr.query();
while(gr.next()) {
gr.incident_state.setValue(IncidentState.CLOSED);
gr.active.setValue(false);
//gr.deleteMultiple();
gr.update();
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Jaydeep Parmar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2018 09:38 PM
Hi,
To Close an Incident :
var incident = new GlideRecord("incident");
incident.addQuery("active", true);
incident.query();
if (incident.next()) {
incident.state=7;
incident.update();
}
To Delete an Incident :
var incident = new GlideRecord("incident");
incident.addQuery("active", true);
incident.query();
gs.addInfoMessage("test"+incident.getRowCount());
if (incident.next()) {
incident.deleteMultiple();
incident.update();
}
Mark Correct if it answers your question.
Thanks,
SaiRaviKiran Akella
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2018 10:27 PM
HI,
May I know the status of this question ?
Can you mark my above answer as correct if it solves your issue?
Thanks,
Ravi