Condition on Schedule Job does not seem to be running
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 07:10 AM - edited 06-03-2024 07:12 AM
I have the following condition on a Schedule jobs (They should be run the 1st, 2nd, 3rd, 4th monday of the month) I have 4 scheduled jobs, one for each.
If I set the time say up 10 minutes on a hourly run it works but I currently have the Scheduled job set to run on Mondays @ 01:00:01. The conditions should be met but the scheduled job does not run.
I'm under the assumption that if the condition is true it will run the Script that fires a flow design.
Here is the condition I'm working with: (anyone see a problem with this and offer easy solution) ***For brevity I am only putting 1st and 2nd Monday conditions as the only thing that changes is the later part of the first line of the if statement)
//1st Monday of the month condition
if (new Date().getDay() == 1 && new Date().getDate() <=7 {
true;
} else {
false
}
// This is for 2nd Monday of the month
if (new Date().getDay() == 1 && new Date().getDate() >= 8 && new Date.getDate() < = 14) {
true;
} else {
false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 03:44 PM
You can take some inspiration from How do I schedule a sys_template to trigger on the... - ServiceNow Community, I do recommend you move to using GlideDateTime rather than Date when it comes to ServiceNow, as it'll account for localisation.