Auto close resolved incidents after 3 business days

snuser10
Kilo Expert

Trying to figure out how to auto close an incident after 3 business days of being in resolved state.   I tried following link (How to close ticket after 3 business days )however, end date here has the correct date but not correct time.   Any one has a solution for that? Appreciate your help!

14 REPLIES 14

Hi,



In this case you needs to write scheduled job to check for the resolved tickets to auto-close after 3 business days.



Write the script something like this, please change the code as per your requirement.



Please correct the code, if I missed something in it.




var g = new GlideRecord('incident');


g.addQuery('state', '6');


g.query();


if(g.next())


{


var days = 3;


var startDate = current.resolved_at;


var endDate = gs.now();


var schedule = new GlideSchedule();


schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule


var duration = schedule.duration(startDate, endDate);


//gs.info(duration.getDurationValue()); // gets the elapsed time in schedule


if(duration == days)


{


g.state = '7'; // set as closed.


}


}




Thanks.


i added a line g.addQuery('number','INC00xxxxx'); right above g.query() to try this for a specific incident but it doesn't work. Does it work for you? Made sure the sys_id was correct for my system.


Chuck Tomasi wrote:



This is built in functionality. The system is already set up to auto close after three days.


Unfortunately the built-in functionality uses calendar days, not business days - it doesn't respect availability schedules.



(default is 1 day in Jakarta now, I believe... I was shocked it'd dropped so short!)


Jaspal Singh
Mega Patron
Mega Patron

Hi,



You can look for System Properties >> System & then search for


find_real_file.png


& as updated by Dave in Jakarta it has been modified to 1 day.