
- 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 11:34 PM
HI Rakesh,
So here we will have to write a scheduled Job. Which will run twice or thrice a day.
This will check when the SLA was created and attached. If the time is more than 5 days without holidays then we will close this.
Please clarify once again.
I am working on script and get back to you asap.
Thank you,
Ashutosh Munot
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:38 PM
Asutosh, appreciate gesture.
Please go ahead.
Regards,
Rakesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 11:20 PM
HI Rakhesh,
I was working on this. I came accross one thing and please clear that. SLA has workflow. SO should it be cancelled when we auto close this SLA>
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2018 01:03 AM
Sorry for late response Ashutosh,
SLA as well as ticket has to be closed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 03:19 AM
Hi Ashutish,
I made some changes in BR and SLA workflow.In SLA , i put set values is 'stage cancelled ' after 100 percentage of SLA Timer.But we want to autoclose the ticket and SLA after 5 days of ticket raised.
BUSINESS Rule:After
stage changes to cancelled
advance:
var gr=new GlideRecord('x_pipi_pmo_table');
gr.addQuery('sys_id',current.task);
gr.query();
while(gr.next()){
gr.status=8;
gr.update();
}