Schedule job should perform autoclose incidents which are in resolved state from last 5 days

The Matrix
Tera Contributor

Trigger a schedule job at mid night 12 . Schedule job should perform autoclose incidents which are in resolved state from last 5 days(update resolution information and resolution code with this incident auto closed by system due to inactive update from last 5 days).

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi @Siddharam Takali 

This happens automatically, default number of days when ServiceNow closes the incident is 7 days.

You just need to update the property to 5 days as per steps mentioned below:

1) Navigate to System properties by typing "sys_properties.LIST" in Application Navigator and hit enter as shown below:

find_real_file.png

Now search for the property Named as "glide.ui.autoclose.time" and just change the value from 7 to 5 as shown below:

find_real_file.png 

Property Link for reference posted below:

https://instance.service-now.com/nav_to.do?uri=sys_properties.do?sys_id=d5c62446c0a8011800cdf450892cec2d

Replace "instance' with your instance name.

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

7 REPLIES 7

OlaN
Giga Sage
Giga Sage

Hi,

You could do this easy with a Flow, would require no scripting at all.

find_real_file.png

shloke04
Kilo Patron

Hi @Siddharam Takali 

This happens automatically, default number of days when ServiceNow closes the incident is 7 days.

You just need to update the property to 5 days as per steps mentioned below:

1) Navigate to System properties by typing "sys_properties.LIST" in Application Navigator and hit enter as shown below:

find_real_file.png

Now search for the property Named as "glide.ui.autoclose.time" and just change the value from 7 to 5 as shown below:

find_real_file.png 

Property Link for reference posted below:

https://instance.service-now.com/nav_to.do?uri=sys_properties.do?sys_id=d5c62446c0a8011800cdf450892cec2d

Replace "instance' with your instance name.

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi @Siddharam Takali 

Also for knowledge sharing want to add here, how this property works. There is a OOB Business Rule named as "incident autoclose" where this system property shown above gets called and this Business Rule is triggered by a Scheduled Job which is "Autoclose Incidents".

So now if you want to set any field values while Incident gets closed you can set it up in a Business rule mentioned above itself and you do not need any code changes here as shown below:

BR Link:

https://instance.service-now.com/nav_to.do?uri=sys_script.do?sys_id=d67b8d9ec0a80118008cd8f0f7f92fae


Replace "instance' with your instance name.

Screenshot for BR where you can set the fields:

find_real_file.png

Posting the Scheduled Job URL as well below for reference:

https://instance.service-now.com/nav_to.do?uri=sys_trigger.do?sys_id=d67e98dac0a8011801393f5054790aa5


Replace "instance' with your instance name.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi @Siddharam Takali 

So my suggestion and preferred method would be the above as shown. But still if this is for learning perspective and you want to write your own Scheduled Job then use the script below:

Script:

closeIncident();

function closeIncident(){
	var gr = new GlideRecord('incident');
	gr.addEncodedQuery('state=6^sys_updated_on<javascript:gs.beginningOfLast5Days()');
	gr.query();
	while(gr.next()){
		gr.state = 7;
		gr.close_notes = 'Incident Resovled by system due to inactivity ';
		gr.update();
	}
}

Screenshot for reference:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke