- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 07-07-2021 03:17 AM
Problem :-As of now , we can't close the MIs(major incident) automatically after been put to resolve by using OOTB Auto Close BR, the major incidents will not be auto close in ServiceNow .We can close a major incident physically(manually ) in the wake of approving the goal and when the major incident is in the Resolved state. Explore to Major Incidents > Open. Open the significant occurrence that you need to close
Solution:- There is a possible solution for the same we can create a Schedule job that run every-day at a particular time and close the major-incident based on the condition.
Lets take an example below:-
We have one scenario where we have to close all the MIs in 45 day after being put to resolve.
So we can create an scheduled job where we will be writing the below code :-
In the below code we need to create one property where we will be defining our date i.e. after how many days the incident should close. In my case it is (glide.ui.autoclose.time.major') .
var ps = gs.getProperty('glide.ui.autoclose.time.major');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addEncodedQuery('major_incident_state=accepted^state=6');// when the incident is in resolved state and accepted)
gr.addQuery('sys_updated_on', '<', gs.daysAgo(pn));
gr.query();
while(gr.next()) {
gs.print(gr.number);
gr.state = 7;
gr.active = false;
gr.closed_by = gr.resolved_by;
gr.update();
}
}
In this way we can auto close the Major Incident.
- 1,093 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
very helpful!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Ravi Gaurav ....
My requirement is 'the auto closer process should be applied to both incidents & Major incidents' . So that both will auto close at the same time.
Do I need to create a new sys property for MIs?
Thanks in Advance