I want a report for incidents which have are opened since 7 days excluding weekends and bank holiday

Harsha Pandey
Tera Expert

Hi everyone,

@Ankur Bawiskar could you please help me on this post.

 

I want a report of incidents which are opened since 7 days excluding weekends and bank holidays that is 7 business days.

I created a scheduled email of report but the issues is that the schedule of the report is being modified as per below script and not the data/records in the report.

I need incident data to be like I mentioned.

 

Below is my script:

 

var answer = false;
gs.info("hi this is for test");
var s = new GlideSchedule("659ca1f61b84734067b5ed7cee4bcb85");
//var w = new GlideSchedule("55ebbbf15f002000b12e3572f2b47714");
var now = new GlideDateTime();
gs.log("testing for report", "Harsha");
if(now.getDayOfWeek() >= 1 && now.getDayOfWeek() <= 5){ //For Monday to Friday
//if (now.getDayOfWeek() == 0) { // For Sunday
    gs.log("day of week", "Harsha");
    if (s.isInSchedule(now)) { // && w.isInSchedule(gdt)){ //For schedule defined for bank holidays
        gs.log("holidays", 'Harsha');
        answer = true;
    }
}
answer;
 
Can you please suggest how to get the incident data in the same way in a report?
 
Thanks,
Harsha
1 REPLY 1

Craig Gruwell
Mega Sage

Hi Harsha,

 

I think you'll want to use something like this (see link below and refer to the section titled "Calculate duration given a schedule") assuming:

1) you have your schedule created to exclude weekends and holidays 

2) the end parameter would be the current date/time, so use new GlideDateTime()

 

https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/script/useful-scripts/concept/c_U...