Skip to content

Commit 142cd6b

Browse files
authored
Scheduled job to trigger event on weekday (#2667)
* Create script.js * Create read.md
1 parent 233e253 commit 142cd6b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Purpose: To send notifications only on business days (Monday to Friday).
2+
3+
Verifies if the current day is a weekday (Monday to Friday).
4+
5+
Action on Valid Business Day:
6+
7+
Triggers a custom event:
8+
9+
Use Case:
10+
11+
Ideal for daily reminders, alerts, or updates that should not be sent on weekends
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(function executeRule(current, previous) {
2+
var today = new GlideDateTime();
3+
var dayOfWeek = today.getDayOfWeek(); // Returns 1 (Monday) to 7 (Sunday)
4+
5+
// Check if it's a weekday (Monday to Friday)
6+
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
7+
8+
var grHoliday = new GlideRecord('cmn_schedule_holiday');
9+
grHoliday.addQuery('date', today.getDate());
10+
grHoliday.query();
11+
if (!grHoliday.hasNext()) {
12+
// Trigger notification
13+
gs.eventQueue('<weekday>', current, '', '');
14+
}
15+
}
16+
})(current, previous);

0 commit comments

Comments
 (0)