
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 05:08 AM
I created a scheduled job to create a request that I only want to generate on Monday thru Friday.
Below is the script I put into the advanced tab on the scheduled job record:
function checkCondition() {
var gdt = new GlideDateTime();
var dayOfWeek = gdt.getDayOfWeekLocalTime();
// Monday is 1, Sunday is 7
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
return true; // Run the job
} else {
return false; // Don't run the job
}
}
However, it is run every day, including Saturday and Sunday.
Have I missed a step?
The job is scheduled to run Daily on the US/Eastern time zone schedule
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 05:09 AM
Did you select the option to have the Flow variable as a boolean True/False ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 05:12 AM
Hi,
Probably a small error, you'll need to call the function within the script also.
Like this:
checkCondition(); // add this line
function checkCondition() {
var gdt = new GlideDateTime();
var dayOfWeek = gdt.getDayOfWeekLocalTime();
// Monday is 1, Sunday is 7
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
return true; // Run the job
} else {
return false; // Don't run the job
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 05:19 AM
Thanks.
Will monitor and see if it creates it again on Saturday this week.
If it doesn't, I will mark as Helpful and Accept as Solution.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 05:27 AM
So I added that script and now it is creating 2 requests daily...
Here is the full script:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2025 11:12 PM
Did you add the entire script to the condition field ?
So the conditionfield also runs the cart-API ?
Since it's kind of a simple logic you want to run in your scheduled job, I would suggest you replace it with a simple Flow instead.
Here's how I would do it.
A flow that runs daily, and first action is to evaluate if it is a weekday or weekend, and depending on the results, run the submit of the catalog item needed.
Script for evaluating the weekend expanded below.