To check if today (current date) is the first Saturday of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 01:58 AM
I have a scheduled job set to run daily but I need to check in condition script that if today is first Saturday of the current month? Then only run the scheduled job.
Can someone please share the code needs to be used for that in the condition area?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 02:01 AM
Please check this old thread for solution.
Scheduled Job - First Saturday of each month
Thanks!
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 02:06 AM
Hi,
in the script or the condition field you can check like this
var gdt = new GlideDateTime();
var dayOfWeek = gdt.getDayOfWeekLocalTime();
var dayOfMonth = gdt.getDayOfMonthLocalTime();
if(dayOfWeek == 6 && dayOfMonth < 7 ){
gs.info("First Saturday");
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 09:13 PM
Hi Ankur,
Thanks for the response but I am wondering how to test this?
If I change my system date to a Saturday, will it show True?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 09:17 PM
Hi,
real time testing can only happen when it's first saturday or the month
try to give some hard-coded date and check if it returns true or false
1) give 1st saturday of May and verify
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader