Scheduled job notification will not be sent on specific days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 12:24 AM
I have a Scheduled Script Execution for Daily Notification For Open Incidents.
it runs daily on 10:00 am.
How to add a condition so that the notification will not be sent on Fridays and Saturdays.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 09:09 PM
Have you been able to think of creating a schedule for this that will make the scheduled job run on that schedule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 09:40 PM
Hello @ofekg ,
Please try to use the code below and see & let me know how it works for you.
// Get the current day of the week (1 = Sunday, ..., 7 = Saturday)
var currentDay = new GlideDateTime().getDayOfWeek();
// Skip sending notifications if it's Friday (6) or Saturday (7)
if (currentDay === 6 || currentDay === 7) {
gs.info('Notification skipped as today is Friday or Saturday.');
return;
}
// Query open incidents
var openIncidents = new GlideRecord('incident');
openIncidents.addQuery('state', 'open');
openIncidents.query();
// Send notifications for open incidents
while (openIncidents.next()) {
gs.eventQueue('incident.daily.notification', openIncidents, openIncidents.sys_id, gs.getUserID());
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket