Send Email Periodically 1 Hour for specific Time

Muhammad Arif B
Tera Contributor

Hi, I have requirement to send email by using Scheduled Email Report every 1 hours but specifically between office hour 8AM until 8PM daily. Anyone can provide script or guidance on how to fulfill this requirement?

Thanks

MuhammadArifB_0-1768380817822.png

 

5 REPLIES 5

4078_TA
Tera Guru

Hi @Muhammad Arif B ,

 

TejasSN_LogicX_0-1768446177335.png

 check here ->  https://www.servicenow.com/docs/bundle/zurich-now-intelligence/page/use/reporting/task/t_ScheduleARe...

 

script :-

 

// Get current system time and convert to local display string
var now = new GlideDateTime();
var displayTime = now.getDisplayValue(); 

// Use substring to grab the two-digit hour directly from 'YYYY-MM-DD HH:mm:ss'
// The hour starts at character index 11
var hour = parseInt(displayTime.substring(11, 13), 10);

// Set answer to true only if the hour is between 8 (8 AM) and 19 (7:59 PM)
if (hour >= 8 && hour < 20) {
    answer = true;
} else {
    answer = false;
}