logo

NJP

Setting the Due date on records

Import · Oct 11, 2021 · article

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

https://docs.servicenow.com/bundle/sandiego-application-development/page/script/server-scripting/con...

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 . 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

View original source

https://www.servicenow.com/community/now-platform-articles/setting-the-due-date-on-records/ta-p/2308026