Exclude Weekends and Holidays for Calculate TTR

Niranjan2
Tera Contributor

Hi,
Iam looking to create a Report which track Time to Resolve Tickets, for this I'm in the process of configuring an Action in flow designer, we already have an action available which calculate the TTR. Looking to exclude Weekends and Hoildays for that. having issue in coding part within the Action. Any help is appreciated.
Attached the current script.

 

 

 

@Ankur Bawiskar @Jaspal Singh 

14 REPLIES 14

Bert_c1
Kilo Patron

hi,

 

I suggest that you post the entire script (as text), it is cut off in the image after referencing the '8 - 5 weekdays excluding holidays' schedule. So folks here can assist you.

Hi @Bert_c1 Thanks for the reply. Below is the code

(function execute(inputs, outputs) {

  var createdOn = new GlideDateTime(inputs.Created);
  var resolvedAt = new GlideDateTime(inputs.Resolved);
 
  var ttr = GlideDateTime.subtract(createdOn, resolvedAt).getDurationValue();
  outputs.time_to_resolve=ttr;
  var schedule = new GlideSchedule();
  schedule.load('090eecae0a0a0b260077e1dfa71da828')// loads "8-5 weekdays excluding holidays" schedule
 
 
})(inputs, outputs);

Ankur Bawiskar
Tera Patron
Tera Patron

@Niranjan2 

you can use GlideSchedule and get the difference. in your schedule ensure you skip the weekends and holidays

check these links on how to subtract using schedule

subtract time from schedule to update task due date 

Calculate Date By Adding or Subtracting Time With A Schedule 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar Thanks for the reply, could you please help me with correcting above script which excludes weekends and holidays using GlideSchedule. I tried but unsuccessful.