SLA by Task Due date


configuration in ServiceNow is generally a pretty straight-forward process once you understand how the system works. One fairly common SLA requirement that isn’t so straight-forward to configure is a task due date-based SLA. This type of SLA is dependent on user-provided input into the ‘Due date’ field on a task record. Of course, you could apply the same concept to any date/time field on any record in the system. The only problem is that there’s no built-in way to set up this type of SLA. This article will show you how this can be accomplished.

Special thanks to James Grinter from ServiceNow for developing this entire solution. My only contribution is to share it with you here.


Create a new ‘Relative Duration’ record

The way to accomplish this customization is to create a new ‘Relative Duration’ record by navigating to ‘System Scheduler -> Relative Durations’ in your left navigation. You can read more about Relative Durations here on the ServiceNow wiki. For what it’s worth, I’ve never found any value in using a relative duration for an SLA until I needed this Due date SLA.

‘Task Due date’ Relative Duration
Name: Task Due date

//Identify 'task' or 'task_sla' as base table
var baseTable = new TableUtils(current.getRecordClassName()).getAbsoluteBase();
if(baseTable == 'task'){
myTask = current;
else if(baseTable == 'task_sla'){
myTask = current.task;
}var dueBy = myTask.due_date.getGlideObject(); //due_date - a glide_date_time field on the associated Task record//Perform relative duration calculation using the 'calculator' variable (which is a DurationCalculator object)
calculator.endDateTime = dueBy;
calculator.seconds = (dueBy.getNumericValue() - calculator.startDateTime.getNumericValue())/1000;
calculator.totalSeconds = calculator.seconds;

Set up the SLA Definition

Once you’ve defined a new relative duration for the ‘Due date’ field you can select that option in your SLA Definition from the ‘Duration type’ field. Because this duration is based on a static date, the ‘Schedule’ field should ALWAYS be ‘–None–‘. Shown in the screenshot below is a sample SLA for change tasks.


If you’ve done everything correctly you should now be able to trigger an SLA that uses the ‘Due date’ field value of a task as the SLA end date!

Date Posted:

June 20, 2012

Share This:


  1. Jonathan July 12, 2012 at 7:01 am

    I have tried to implement this and its working nicely, any idea why the “Actual elapsed percentage” would not be calculating. All the other details are working properly. The “Actual time left” and the “Actual elapsed time” are moving, however the “Actual elapsed percentage” is not doing anything. One thing to note is if I choose “Run SLA calculation” the percentage does update… any thoughts?

    • Mark Stanger July 12, 2012 at 7:27 am

      Some of the SLA calculations only run via scheduled jobs at specific intervals depending on how close you are to breaching the SLA. This behavior should be consistent for all SLAs whether you use the method described here or not.

  2. Mark Sandner July 26, 2012 at 11:34 am

    I too am appreciative of this article. After spending time reading up on SLAs, which I hadn’t implemented before, I wanted to use SLA on catalog items, or rather their tasks. So I wondered where the due date was coming from. The date is set by the task in the workflow, which is pretty straight forward. But I am using a ‘generic’ workflow for many SC items, so the tasks are never constant. If anyone has any suggestions on how to get around this, I would really love to hear them. I would think that the SLA has to be on the task rather than the item, as there may be many tasks associated with a single item. I am only using the generic SC Item workflow for more simpler requests, so maybe an SLA on the item IS possible. Maybe I am missing something about SLA and making a mountain out of a molehill, but it shouldn’t be that difficult should it? Once I have it sorted out, I’ll post my process here. Thanks, Mark S

  3. Mark Sandner July 26, 2012 at 2:52 pm

    I forgot to mention, that after implementing this, the “Actual elapsed percentage” and “The Actual Time Left”, are not doing anything. There is a StartTime, and Planned End Time populated. If I choose “Run SLA calculation”, The “End Time” field is blank, and the Actual Percentage, Actual Time Left, and Business related time fields are all at 00:00:00. Do I need to have an End Time in there for it to work? Many Thanks

    • Mark Stanger July 27, 2012 at 9:11 am

      Hey Mark,
      I’m not sure what might be going on. The solution above should work in the exact same way as an SLA. You might check to make sure your other SLAs are operating correctly.

      • Jeremy July 27, 2012 at 2:40 pm

        I would like to also state that my times are not calculating correctly either. It is populating the date as the Task SLA date, but does not calculate percentage or time lapsed. Other SLAs that do not trigger this Due Date variable are working as designed.

  4. Jason September 7, 2012 at 2:56 am

    Hi Mark,

    Ive also found these issues. During research I came across this article Interesting part of this states:

    Relative Duration

    The biggest thing here is to understand that Relative Duration does not work with Pause Time. To avoid confusion we now hide the Pause Condition field on Relative Duration SLA Definitions. The next biggest thing to understand is the the “current” object is not supported in the scripted section of a Relative Duration. If you use it you will get results, but they will not be consistent. This means that you can not use Relative Duration SLAs to design an SLA that will have a different duration depending on some value on the Task record.

    In light of this not sure we can do this….

    • Mark Stanger September 7, 2012 at 7:10 am

      Seems like we’re getting different feedback from SN about the viability of this solution. Thanks for the feedback, I’ve seen enough :). Although I’d like to keep this article public I’m going to retire it for the time being. Hopefully ServiceNow addresses these limitations soon.

Comments are closed.




Fresh Content
Direct to Your Inbox

Just add your email and hit subscribe to stay informed.