Send Notification Every Month Second Monday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 02:04 AM
Hello Team,
I need to send a notification every month on the second Monday. If the Monday happens to be a holiday, the notification should be sent on the next working day.
Could you please guide me on how to achieve this using Flow Designer?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 03:34 AM - edited 05-11-2025 11:40 PM
Hi @Mark Wood
This can easily be done with scheduled job with below script:
Trigger Type:
Script:
var now = new GlideDateTime();
var dayOfMonth = now.getDayOfMonthLocalTime();
var dayOfWeek = now.getDayOfWeekLocalTime(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
// Check if it's the second Monday of the month
if (dayOfWeek == 1 && dayOfMonth >= 8 && dayOfMonth <= 14) {
var sched = new GlideSchedule("your_holiday_schedule_sys_id");
//This loop will automatically be skipped if its not holiday
while (sched .isInSchedule(now)) {
now.addDaysLocalTime(1); //this will keep on adding days until it is holiday
}
gs.eventQueueScheduled("event_name", current, "param1", "param2", now);
}
}
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 11:10 PM - edited 05-12-2025 12:09 AM
Hello @Abhijit4,
There seems to be a mistake in your code. You need to initialize the object for the GlideScheduled API and use that object to check whether the record is within the schedule or outside it. Currently, you're checking it using the GlideRecord object, which I believe won’t work as intended. I’ve attached the updated code below.
Thank you
var now = new GlideDateTime();
var dayOfMonth = now.getDayOfMonthLocalTime();
var dayOfWeek = now.getDayOfWeekLocalTime();
if (dayOfWeek == 1 && dayOfMonth >= 8 && dayOfMonth <= 14) {
var grSchedule = new GlideRecord('cmn_schedule');
grSchedule.addQuery('name', 'your_holiday_schedule_name');
grSchedule.query();
if (grSchedule.next()) {
var schedule = new GlideSchedule(grSchedule.sys_id);
// Keep moving forward until we find the next valid (working) day
while (schedule.isInSchedule(now)) {
now.addDaysLocalTime(1);
}
gs.eventQueueScheduled("event_name", current, "param1", "param2", now);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 11:45 PM
@Abhijeet_Pawar You are absolutely right, I missed to use GlideSchedule. Now I have updated my code to reflect GlideSchedule. Also, we may not need to glide into cmn_schedule table. We can store schedule sys_id in system property and use it directly.
Also, your while condition should be other way around
while (schedule.isInSchedule(now)) { // not(!) should not be used here as schedule holds holiday dates so we should loop until date is not in schedule ( which means not a holiday )
now.addDaysLocalTime(1);
}
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2025 04:28 AM
difficult to achieve this using flow designer, you can use the approach shared by @Abhijit4 and let us know the feedback
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader