We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to add stop condition in SLA

SuvithaMuru
Tera Contributor

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.




 

3 REPLIES 3

Tanushree Maiti
Tera Patron

Hi @SuvithaMuru 

 

Use this : Follow_up_date Relative on or before 7 working days from now

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Ankur Bawiskar
Tera Patron

@SuvithaMuru 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@SuvithaMuru 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader