Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tiagomacul
Mega Sage
Mega Sage

INCIDENT:: Auto close configuration

 

Image Description
find_real_file.png 01. >> Incident > Administration > Incident Properties
find_real_file.png 02. Number of days (integer) after which Resolved incidents are automatically closed. Zero (0) disables this feature. (glide.ui.autoclose.time) and enter the number of days.
   
find_real_file.png 03. >>System Scheduler > Scheduled Jobs.
find_real_file.png 04. Search and Open the Autoclose Incidents schedule
find_real_file.png 05.
   
find_real_file.png 06. >> System Definition > Business Rules
find_real_file.png 07. Search by "Incident autoclose"
find_real_file.png 08. This script will run accordingly property.

 

08. Original Script

// This script automatically closes incidents that are resolved
// and haven't been updated in the specified number of days.
// This number is a property in System Properties.
// To place a comment in the incident, uncomment the "gr.comments" line.

autoCloseIncidents();

function autoCloseIncidents() {
	var ps = gs.getProperty('glide.ui.autoclose.time');
	var pn = parseInt(ps);
	var queryTime = new GlideDateTime();
	queryTime.addDaysUTC(-pn);

	if (pn > 0) {
		var gr = new GlideRecord('incident');
		gr.addQuery('incident_state', IncidentState.RESOLVED);
		if (gs.getProperty('com.snc.incident.autoclose.basedon.resolved_at', 'false') === 'true') {
			gr.addQuery('resolved_at', '<', queryTime);
		}
		else {
			gr.addQuery('sys_updated_on', '<', queryTime);
		}
		if (pm.isActive('com.snc.incident.mim')) {
			var mim = gr.addNullQuery('major_incident_state');
			mim.addOrCondition('major_incident_state', '!=', new sn_major_inc_mgmt.MajorIncidentTriggerRulesSNC().MAJOR_INCIDENT_STATE.ACCEPTED);
		}
		gr.query();
		while(gr.next()) {
			gr.incident_state = IncidentState.CLOSED;
			//  gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
			gr.active = false;
			gr.closed_by = gr.resolved_by;
			gr.update();
		}
	}
}

Escrito inicialmente para Release Madrid

image

Summary

Configure incidents to close automatically - Oficial documentation

 

Artigos-publicados

 

Direct LINKs:

Step: 2

https://<instance>.service-now.com/nav_to.do?uri=%2Fsystem_properties_ui.do%3Fsysparm_title%3DIncident%2520Management%2520Properties%26sysparm_category%3DIncident%2520closure,%2520Incident%2520Re-open,%2520Copy%2520Incident%2520and%2520Create%2520Child%2520Incident,%2520Incident%2520Form%2520Fields%2520Configuration

step 8

https://<instance>.service-now.com/nav_to.do?uri=%2Fsys_script.do%3Fsys_id%3Dd67b8d9ec0a80118008cd8f0f7f92fae%26sysparm_record_target%3Dsys_script%26sysparm_record_row%3D1%26sysparm_record_rows%3D1%26sysparm_record_list%3DnameSTARTSWITHincident%2Bautoclose%255EORDERBYname

 

Version history
Last update:
‎11-29-2023 04:52 AM
Updated by:
Contributors