SLA Breach on due date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2025 10:55 AM
I have a client who wants a task to have a 4 day SLA.
They want the SLA to start 4 business days before to the task's Due Date.
I am trying to use a script in the Relative Duration table (cmn_relative_duration).
The script appears in the SLA Definition's "Duration Type" choice field.
I don't see much documentation for this type of script.
I'm using another Relative Duration script for reference ("Breach on Due Date")
I see in the example the use of "calculator", is that how we set the duration as in:
calculator.endDateTime = dueDate;
The challenge is that the client doesn't want the SLA to be breach if someone specifies a Due Date sooner than the SLA (4 days). They don't want an SLA to "Breach on Submission".
Your suggestions are welcomed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 04:36 AM
Hi @mikereaves
The calculator object is a GlideScheduleDurationCalculator. You can manipulate it like this:
calculator.endDateTime = dueDate;
calculator.subtractTime(4 * 24 * 60 * 60); // 4 days in seconds, though this is absolute not business time
But to subtract business days, you should use:
calculator.setEndDateTime(dueDate);
calculator.calcRelativeStartDate("-4 business days");
var dueDate = new GlideDateTime();
dueDate.setDisplayValue(task.due_date);
if (!dueDate) {
// If there's no due date, do nothing – SLA won't start
calculator.setStartDateTime(null);
calculator.setEndDateTime(null);
answer = false;
return;
}
// Set end time as due date
calculator.setEndDateTime(dueDate);
// Calculate 4 business days before due date
calculator.calcRelativeStartDate("-4 business days");
answer = true;
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards
Deepak Sharma