- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2017 09:28 PM
Hey John,
Can you help me out a bit more? I'm a bit new to scripting and I'm afraid I just can't quite get my head around the idea of extending a SLA condition class with a separate script include. So instead what I've done is cloned the default "SLAConditionBase", but now I'm stuck on how to actually edit it to include my custom SLA condition class.
Here's the function I have written (taskID should have been taskGlideRecord, to make it clear that I'm expecting a GlideRecord object as a parameter)
function taskCreatedWithinSchedule(taskID,scheduleName){
var taskCreated = new GlideDateTime(taskID.sys_created_on);
var scheduleRecord = new GlideRecord('cmn_schedule');
scheduleRecord.get('name',scheduleName);
var scheduleGlide = new GlideSchedule(scheduleRecord.sys_id,scheduleRecord.time_zone);
return scheduleGlide.isInSchedule(taskCreated);
}
------------------------------
It should work when you call it like
var inc = new GlideRecord('incident')
inc.get(thing,thingthatmatches)
taskCreatedWithinSchedule(inc,'8-5 weekdays')
-------------------------
I'm just really really stuck on how to edit the default code below to incorporate the custom function.
// True if an instance of this SLA should be attached and started
attach: function() {
if (!this._conditionMatches(this.sla.start_condition))
return false;
return (!this.complete() && !this.cancel()); // don't start, if completion (stop) condition is also true
},