Restrict time on schedule Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 06:22 AM
Hello Experts,
I want to acheive the below requirement
Restrict the slot 5am to 11am on creating a schedule report. How can i acheive this?
Thanks,
Nithya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 03:08 AM
Hello @Community Alums
Just change the type of the client script to Onsubmit and you can reuse the script like below.
This works fine. I have tested it.
function onSubmit() {
//Type appropriate comment here, and begin script below
var start = "05:00:00";
var end = "11:00:00";
var actual = g_form.getValue('run_time');
if ( actual >= start && actual <= end){
//if(actual <= end) {
g_form.addErrorMessage("Time not allowed between 5 -11");
g_form.clearValue('run_time');}
}
Please mark it Correct and Hit Like if you find this helpful!
Regards,
Karthiga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 03:20 AM
Hi Karthiga,
Issue am facing while changing the existing schedule Report after submitting Time value set to before what they are mentioned. But for below script is working for new creation of schedule report but not for existing one.
Thanks,
Nithya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 10:07 PM
@Community Alums
there is no OOB slot selection on scheduled report form
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 05:57 AM
Hello Nithya,
To restrict the slot 5am to 11am on creating a schedule report in ServiceNow, you can use the Conditional and Condition fields in the Scheduled Reports form. These fields allow you to specify a script that evaluates whether the report should run or not. For example, if you want to run a report only between 5am and 11am on weekdays, you can use this script in the Condition field:
var s = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae"); //sys_id of the OOB 8-5 weekdays schedule
var gdt = new GlideDateTime();
var hour = gdt.getNumericValue().substring(8,10); //get the hour part of the current date/time
s.isInSchedule(gdt, "US/Pacific") && hour >= 5 && hour < 11; //check if the current date/time is in the schedule and the hour is between 5 and 11
This script will return true if the current date/time is in the 8-5 weekdays schedule and the hour is between 5 and 11, and false otherwise. You can change the schedule sys_id and the timezone according to your needs.
I hope this helps.
Kind Regards,
Swarnadeep Nandy