
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-10-2021 11:34 PM
I was requested by a customer recently to calculate the due date for a case which was let's say X business days from the date of create/update etc.,
Now we know that setting a due date can be a challenging task due to a lot of moving parts, such as scenarios involving e.g. Holidays, non-business hours, Out of office hours, etc. leading up to a lot of coding and maintenance too
Due date may have several dependencies too e.g. SLA timeline, dashboard, actions, etc. hence it's not wrong to say that it can play a very critical part to drive the overall workflow
Thanks to the GlideDuration API, we can now easily calculate the due date on a record in line with our schedules. Infact, there are sample scripts provided at the link below which you can copy-paste in your BR, Flow, workflow to calculate the due date
You can calculate relative durations too...Relative duration is very similar to simple duration except a piece of script is used to determine what parts of a day to remove from the difference calculation.
This script is stored in table cmn_relative_duration and can be examined by navigating to System Scheduler > Schedules > Relative Durations. There are some example relative duration scripts in the out-of-the-box instance.
Hope this article helps you and makes your life easy when it comes to date calculations, as we can certainly re-use this logic not just for due date but other use cases too
- 1,607 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Quick note, the URL Sachin gives above has been changed to:
https://docs.servicenow.com/bundle/rome-application-development/page/script/server-scripting/concept/c_DrtnClDueDate.html#c_DrtnClDueDate