We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

background script to close all incidents.

akshayjain
Tera Expert

What should I write in background script to close all incidents or delete all incidents

6 REPLIES 6

sachin_namjoshi
Mega Patron

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

Jaydeep Parmar
Kilo Guru

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

 

find_real_file.png

 

SaiRaviKiran Ak
Tera Guru

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

HI,

 

May I know the status of this question ?

Can you mark my above answer as correct if it solves your issue?

 

Thanks,

Ravi