
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2017 09:36 PM
Hi Guys,
I am trying to mass close 70,000ish Incident records.
There are mandatory fields that need to be completed otherwise the SLA Clock will keep running.
My Mandatory fields are: u_cause_code, u_resolution_code, u_cause_ci, u_solution, u_business_impact, u_cause_summary & u_incident_outage.
Cause code and resolution code are choice fields, cause CI field is a reference and business impact, resolution summary are free text.
Incident outage is a yes/no choice.
Each incident is identified by the same "assigned to" support group and generated "short description".
I am assuming this will be done via a clean-up script, my knowledge on scripting this type of thing is little to none.
Any assistance on this or aducation will be greatly appreciated.
Thank you,
Phil.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2017 07:35 PM
Hi Philip,
Either you can run a background script to do the same which is already provided by Aanchal or you can create buisness rule .
This article might be helpful for you :
http://wiki.servicenow.com/index.php?title=Closing_Multiple_Incidents#gsc.tab=0
The conditions can be modified according to your requirements.
Also you might want to write a Background Script to close the incidents required from back end and setting the workflow as well as to false so that no Notifications gets triggered while closing the Incidents as per the script mentioned below:
Script:
var gr = new GlideRecord('incident');
var string='active=true^state=2'; //Replace your Query here
gr.addEncodedQuery(string)
gr.query();
while(gr.next())
{
gr.setWorkflow(false); //This would not allow any Notifications to get trigger while closing
gr.autoSysFields(false);
gr.state = 10; //Replace your Closed State value here
gr.update();
}
In the code shared above you can get your Query required by simply Navigating to the list view of incidents and filter the Records which you want to close and then Run the filter. Post Run Right click on the query and copy the same as shown below:
Hope this helps.Mark the answer as correct/helpful based on impact.
Thanks,
Aditya Telidevara

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2017 09:55 PM
This should be helpful:
====================
var vabObj= new GlideRecord("incident");
//Add your qualification to locate those 70,000+ incident records
vab.addQuery("Field","Value");
vab.addQuery("Field","Value");
vab.addQuery("Field","Value");
//Execute Query
vab.Query();
//Add your Hard Coded Values for all these records
vab.setValue("u_cause_code","<Choice_Value>");
vab.setValue("u_resolution_code","<Choice_Value>");
vab.setValue("u_cause_ci","<sys_ID_of_reference_Value>");
vab.setValue("u_business_impact","<Add_Your_Free_Text>");
vab.setValue("u_cause_summary","<Add_Your_Free_Text>");
vab.setValue("u_incident_outage","<Enter_Yoiur_Value");
//Update status to closed
vab.setValue("state","Closed");
//Update All
vab.updateMultiple();
====================

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2017 02:17 PM
WOW Awesome,
Thanks Vab, i will give this a crack and cross my fingers
I really appreciate your time on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2017 09:58 PM
Hi Phil
Below script will help you to do so
var inc_query = "" // setup a query here to find the 70000 required incident to update
var gr = new GlideRecord('incident');
gr.addEncodedQuery(inc_query);
gr.query();
while(gr.next()){
gr.u_cause_code = "" // put the cause code. the choice value of the choice
gr.u_resolution_code = ""// put resolution code.The chocie value of the resolution code
gr.u_cause_ci = "" // put the Cause CI
gr.u_solution = ""; // put values as required
gr.u_business_impact =""; //put values as required
gr.u_cause_summary =""; // put values as required
gr.u_incident_outage = ""; // put values as required
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2017 09:59 PM
This will take 70,000+ iterations of while loop.
I reckon leverage "updateMultiple()" rather than looping through each object.