How to add stop condition in SLA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
Hi everyone,
I need help configuring an SLA stop condition.
In the sn_grc_issue table, I want the SLA to stop when the Follow up date is less than or equal to 7 working days.
The Follow up field is a date field.
Could someone please guide me on how to achieve this?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
this is not feasible directly with Stop condition in SLA as you want to compare date field to Today + 7 working days.
Also system won't automatically check and compare date and stop
Workaround:
1) create a custom field such as u_stop_sla and set it TRUE when Follow Up is within 7 business days based on your schedule. For this create daily scheduled job and iterate over all the records and then update the flag
2) Configure STOP Condition of SLA as u_stop_sla=TRUE
3) SLA stop condition requires some update on Record then only it will stop
Something like this in scheduled job, please enhance
var SCHEDULE_SYS_ID = 'PUT_YOUR_SCHEDULE_SYS_ID_HERE';
var SCHEDULE_TZ = gs.getProperty('glide.sys.default.tz', 'UTC');
var BUSINESS_HOURS_PER_DAY = 8; // change to match your schedule
var FLAG_FIELD = 'u_stop_sla';
var today = new GlideDateTime();
var durationMs = 7 * BUSINESS_HOURS_PER_DAY * 60 * 60 * 1000;
var duration = new GlideDuration(durationMs);
var schedule = new GlideSchedule();
schedule.load(SCHEDULE_SYS_ID, SCHEDULE_TZ);
var thresholdGdt = schedule.add(today, duration);
var thresholdDate = new GlideDateTime(thresholdGdt);
var gr = new GlideRecord('sn_grc_issue');
gr.addNotNullQuery('follow_up');
gr.query();
while (gr.next()) {
var followUp = new GlideDateTime(gr.getValue('follow_up')); // date field, returns yyyy-MM-dd
var shouldStop = false;
if (followUp.getNumericValue() <= thresholdDate.getNumericValue()) {
shouldStop = true;
}
if (gr.getValue(FLAG_FIELD) != shouldStop.toString()) {
gr.setValue(FLAG_FIELD, shouldStop);
gr.update();
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
