The CreatorCon Call for Content is officially open! Get started here.

Custom Pause SLA criteria.....

davidvetter
Tera Contributor

Hi all

I need to set up some custom pause SLA criteria and not sure how to pull it off.

 

1. Need to be able to pause for emergency weather, gov't shutdown, etc....but be able to have the pause be backdated to when the emergency (or any other event really) occurred, and the duration. My belief is this should push the currently active SLA for a record forward as many days as the event duration was.

 

2. Need to be able to pause for a two week Corporate holiday office closure in December (annually)

 

Thank you in advance for your suggestions.

3 REPLIES 3

Rafael Batistot
Kilo Patron

vignesh parthib
Tera Guru

Hi @davidvetter 

1. Annual Corporate Holiday SLA Pause (December)
Automatically pause SLA timers during the company’s holiday closure  every year.

  • Steps to Implement:
  • Create a Custom Schedule
  • Go to: System Scheduler > Schedules
  • Create a new schedule (e.g., “Business Hours – Exclude Holidays”)

Add Holiday Exception

  • In the schedule, add a recurring exception from Dec 18 to Dec 31
  • This defines the annual office closure

Apply Schedule to SLA

  • Open your SLA Definition
  • Set the Schedule field to the custom holiday schedule

2. Emergency Events (Weather, Government Shutdowns, etc.) - There is no OOB approach

 

  • You create a FIX script or Schedule job 

  • define the pause start and end directly in the script (pauseStart, pauseEnd)

  • The script finds all active SLAs (stage = in_progress)

  • For each SLA, it calculates how much time overlaps with the pause window

  • That overlap is added to pause_duration, pushing the SLA target out accordingly

 

var pauseStart = new GlideDateTime('2025-12-20 00:00:00'); // yyyy-MM-dd HH:mm:ss
  var pauseEnd = new GlideDateTime('2026-01-03 23:59:59');

  // Query all active SLAs (In Progress)
  var taskSLAs = new GlideRecord('task_sla');
  taskSLAs.addQuery('stage', 'in_progress');
  taskSLAs.query();

  while (taskSLAs.next()) {
    // SLA start and now (or SLA end if you want)
    var slaStart = new GlideDateTime(taskSLAs.start_time);
    var slaEnd = new GlideDateTime(gs.nowDateTime()); // current time, or taskSLAs.sys_updated_on

    // Calculate overlap between SLA active period and pause window
    var overlap = getOverlapInSeconds(slaStart, slaEnd, pauseStart, pauseEnd);

    if (overlap > 0) {
      // Add overlap time to pause_duration (in milliseconds)
      taskSLAs.pause_duration = (taskSLAs.pause_duration || 0) + (overlap * 1000);
      taskSLAs.update(); // update triggers SLA recalculation
    }
  }

  // Helper function to calculate overlap in seconds
  function getOverlapInSeconds(slaStart, slaEnd, pauseStart, pauseEnd) {
    var start = Math.max(slaStart.getNumericValue(), pauseStart.getNumericValue());
    var end = Math.min(slaEnd.getNumericValue(), pauseEnd.getNumericValue());
    return end > start ? Math.floor((end - start) / 1000) : 0;
  }

 

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."

FernandoUrrutia
Tera Contributor

You must create "Business Calendars"...explained... Your next step this ..mmm...create a new Business Calendar containing non-working dates (including your vacation weeks, legals, freezze and anything date like you and your business). Then assign that calendar to your SLA Definitions using the Schedule field. Simple...but you can try with script, but this is not necesary.. for this user case.

Fernando Urrutia | LinkedIn

Consultor Certificado en ServiceNow desde 2018

Especialista en ITSM, Mejora Continua, Soporte y Administración

 Solex – Soluciones Expertas S.A.