- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2016 09:34 AM
Hi all,
I have a requirement to measure a vendors SLAs and have come into a bit of a problem. the criteria is as follows
1. They have 2 sets of SLA hours: Core hours are 07:00 - 19:00 and have a 30 minute response SLA. 19:00 - 07:00 and have a 45 minute response SLA
2. They always the team that create the incidents so I need to build this on the basis on when we assign them the incidents.
When I assign them an incident, both SLAs attach but only 1 clock runs.
What I am trying to achieve is that the SLAs only get attached to the incident if the incident is assigned to them during the set hours. 07:00 - 19:00 OR 19:00 - 07:00
Has anyone done this? If so, how did you get this working and can you share it.
Thanks all for your help.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 05:45 AM
I tried this and it worked:
(function executeRule(current, previous /*null when async*/) {
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '8-5 Weekdays');
gs.addInfoMessage('Checking against schedule: ' + schedRec.sys_id);
var sched = new GlideSchedule(schedRec.sys_id);
if(sched.isInSchedule(new GlideDateTime())){
gs.addInfoMessage('in schedule');
current.u_business_hours = 'true';
}else{
gs.addInfoMessage('not in schedule');
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2016 02:32 PM
Here's a thread with similar request: SLA Triggered based on off working Hour and working hour
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 04:35 AM
Hi Michael,
Thanks for the thread, I have gone through it and have tried to implement it, I have had to modify it slightly (as we do) but it doesn't seam to run as what I was expecting.
function onBefore(current, previous) {
//This function will be automatically called when this rule is processed.
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', "WP VSLA");
gs.addInfoMessage('line 5 script run');
var sched = new GlideSchedule(schedRec.sys_id);
if(!sched.isInSchedule(new GlideDateTime())){
current.u_business_hours = 'true';
gs.addInfoMessage('line 9 script run');
}
}
When I run the script to see if it flags field it fails and I am just not seeing where I am going wrong.
Can you let me know your thoughts.
Thanks for your help so far.
Lucien

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2016 05:45 AM
I tried this and it worked:
(function executeRule(current, previous /*null when async*/) {
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '8-5 Weekdays');
gs.addInfoMessage('Checking against schedule: ' + schedRec.sys_id);
var sched = new GlideSchedule(schedRec.sys_id);
if(sched.isInSchedule(new GlideDateTime())){
gs.addInfoMessage('in schedule');
current.u_business_hours = 'true';
}else{
gs.addInfoMessage('not in schedule');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 09:55 AM
Hi Michael,
Thank you for your help with this, it worked well and does everything I needed.
Kind regards,
Lucien