
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 10:11 PM
HI Every One,
We have an issue i.e., The SLA is attached when the status is 'Resourcing in progress' and the duration is 3 days. And the issue is the 5th day of the SLA will be Auto Close.We don't know how can be done this Issue.Can anyone knows please help me to how can i achieve this.
Regards,
Rakhesh.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2018 01:40 AM
HI Guys,
Final Script:
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
schedule.setTimeZone(gs.getUserTimeZone());
//Get the current date/time in correct format for duration calculation
var startDate = new GlideDateTime();
startDate.setDisplayValue(gs.nowDateTime());
gs.print('Actual '+startDate);
var getSla = new GlideRecord('task_sla');
getSla.addQuery('stage','in_progress');
getSla.addQuery('has_breached',true);
//getSla.addQuery('sys_id','b2356ff6db230300e77dd450cf9619a6');
getSla.query();
while(getSla.next())
{
//Query for resolved incident records
var gr = new GlideRecord('incident');
//gr.addQuery('state', 6);
gr.addQuery('sys_id',getSla.task);
gr.query();
while(gr.next()){
var endDate = new GlideDateTime();
endDate.setDisplayValue(gr.opened_at);
gs.log(endDate);
gs.log('Start '+getSla.start_time.getGlideObject());
//Close any records that have not been updated in 'pn' number of days
//Date difference calculated based on specified schedule
var duration = schedule.duration(endDate,startDate).getDayPart();
gs.log('Difference '+duration);
if(dif >= 5){
gr.state = 7;
gr.active = false;
//gr.comments = 'Incident automatically closed after ' + pn + ' hours in the Resolved state.';
gr.update();
}
}
}
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 10:38 PM
HI Rakesh,
So you want to close this SLA after 5 days of it attachment.
Please clarify. If so then i have script with me/
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 10:42 PM
Hi Ashutosh,
Thanks for responding to my issue. Yes we need to auto close the SLA after 5 days.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 10:57 PM
HI Rakhesh,
Do you want to exclude weekends or not?
Thank you,
Ashutosh
Please Hit ✅Correct, âÂ��Helpful, or ��Like depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 11:04 PM
Yes Ashutosh,We want to exclude weekends.