The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Scheduled Report - Periodically but only during business hours

JBrennan
Giga Contributor

Hello all,
I was hoping somebody could help, I am trying to schedule a Report to run Periodically (every hour) which is fine but I would only like it only to run every hour during business hours (8am - 6pm). I'm guessing/hoping it as easy as adding a 'condition' but this/Java is not where my expertise lay (or is it lie). Thanks in advance.

3 REPLIES 3

CapaJC
ServiceNow Employee
ServiceNow Employee

I think the following would work.

1) Create a Schedule representing your business hours (System Scheduler > Schedules)
http://wiki.servicenow.com/index.php?title=Using_Schedules
2) Check the "Conditional" checkbox on the scheduled report, set Run to "Periodically", Repeat interval to one hour
3) in the Condition field, use the following script (replace the timezone with your timezone, replace the 32-character sys_id with the sys_id of the Schedule you created - you can get that by right-clicking it in the Schedules list and selecting Copy sys_id):



var s = new Packages.com.glide.schedules.Schedule("08fcd0830a0a0b2600079f56b1adb9ae");
var gdt = new GlideDateTime();
s.isInSchedule(gdt, "US/Pacific");

The script is for a pre-Calgary release instance. For Calgary or later, the following script is preferred:


var s = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae");
var gdt = new GlideDateTime();
s.isInSchedule(gdt, "US/Pacific");


And the following always helps me 🙂
http://grammar.quickanddirtytips.com/lay-versus-lie.aspx


JBrennan
Giga Contributor

Perfect, many thanks CapaJC.


Dear team,

Please share the updated condition to be used in other Time zones, I need Central European for now.

Many thanks