Set SLA Breach Date from Incident field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 10:05 AM
Community!
I'm trying to have the Breach Date on the task_sla update to a custom date field I created on the incident form using the Relative Duration script below from a previous community post regarding SLAs. It isn't working unfortunately. Wondering if someone had a better way of scripting this out. I want the Breach Date to update every time the form is saved. Thanks in advance!
/* This relative duration script will set the Breach Time of the Task SLA to the value in the "Due date" of the Task.
If the "Due date" field is available on the Task form and editable then this effectively allows the user to specify the
Breach Time of the SLA.
If the Due Date field is empty or in the past, the script will instead set the Breach Time of the SLA to 1 second
after the Start time
*/
(function() {
var startDateMs = calculator.startDateTime.getNumericValue();
var dueDate;
// Work out if "current" is a Task record or Task SLA and then get the "due_date" element from the Task
var tableName = current.getTableName();
if (tableName) {
var baseTableName = GlideDBObjectManager.getAbsoluteBase(tableName);
if (baseTableName == "incident")
dueDate = current.getElement("incident.u_my_due_date");
else if (baseTableName == "task_sla")
dueDate = current.getElement("task.due_date");
}
// if we've got a "due_date" and it's after our SLA's Start time then use it
// otherwise we'll have to default to the same as Start Time plus 1 second (i.e. instant breach of SLA)
if (dueDate && !dueDate.nil() && dueDate.dateNumericValue() > startDateMs)
dueDate = dueDate.getGlideObject();
else {
g_form.setValue("planned_end_time", "u_my_due_date");
}
// if we have a schedule then check if the Due Date is in it and if it isn't
// find the next time we are in the schedule
if (calculator.schedule && !calculator.schedule.isInSchedule(dueDate))
dueDate.add(calculator.schedule.whenNext(dueDate, calculator.timezone));
// set the endDateTime property of the calculator object to dueDate
calculator.endDateTime = dueDate;
calculator.calcScheduleDuration();
})();
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 12:55 PM
I'm using part of the solution here, maybe this will work better:
Solution: presenting color-coded elapsed SLA resolution time in the incident lists
including the system property: glide.sla.calculate_on_display
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 02:24 PM
Thanks, but, that's not what I'm looking for. I need a script which will pull a date field (custom not OOB) from the incident form and populate it on the breach date field in the attached SLA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2021 11:07 PM
Hi,
I have similar requirement, If you have solution for this kindly share.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2024 11:38 AM - edited ‎08-28-2024 11:39 AM
Hi @knight202 , Have you got any solution for this?
I have the same requirement