How to auto Resolve Incidents that are 30 days or older

velvet
Mega Guru

find_real_file.pngfind_real_file.png

1 ACCEPTED SOLUTION

Create a scheduled job: 

find_real_file.png

 

Create a script include:find_real_file.pngBelow is the code from the screenshots:

Scheduled Job:

new closeIncidents().close();

Script Include: 

 

var closeIncidents = Class.create();
closeIncidents.prototype = {
    initialize: function() {
    },
	
	close: function() {
		var incidents = new GlideRecord("incident");
		incidents.addEncodedQuery("active=true^sys_created_on<=javascript:gs.beginningOfLast30Days()");
		incidents.query();
		while(incidents.next()) {
			incidents.state = 6;
			incidents.update(); 
		}
	},

    type: 'closeIncidents'
};

 

Please mark this as correct/helpful if it resolved your issue!

View solution in original post

6 REPLIES 6

It is being set to resolved.

//This is setting the state to resovled
incidents.state = 6; 

 

You can rename the function names/scheduled job name if you need to. 

Please mark this as correct/helpful if it resolved your issue!

Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!