- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:15 AM
hi,
I have a backlog of more than 1000 incidents which i want to close in one attempt which are pending from last 6 months.
how can i achieve it ?
thanks all
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:22 AM
Hi,
You can write a fix script which fetches the list of incidents that are open from last 6 months. You can change the filter as you need in the below code.
var gr = new GlideRecord("incident");
gr.addEncodedQuery("stateNOT IN6,7,8^sys_created_on>=javascript:gs.beginningOfLast6Months()");
gr.query();
while(gr.next()) {
gr.state=6; //closed state
//put other fields if anythign to fill in (like mandatory ones during close)
gr.setWorkflow(false);
gr.update();
}
Mark the comment as a correct answer and helpful if this solves the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:22 AM
Hi,
You can write a fix script which fetches the list of incidents that are open from last 6 months. You can change the filter as you need in the below code.
var gr = new GlideRecord("incident");
gr.addEncodedQuery("stateNOT IN6,7,8^sys_created_on>=javascript:gs.beginningOfLast6Months()");
gr.query();
while(gr.next()) {
gr.state=6; //closed state
//put other fields if anythign to fill in (like mandatory ones during close)
gr.setWorkflow(false);
gr.update();
}
Mark the comment as a correct answer and helpful if this solves the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:29 AM
used above script and it worked.
just one query the above line where you are making wf false will it also affect the business rules as well.
thanks for the help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:34 AM
yes, it will stop triggering any BRs or workflows associated to those updated records.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 03:34 AM
Do be aware that this will perform pretty poor when it concerns a lot of records.
Consider using .updateMultiple instead.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field