Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Server-Side Components/Scheduled Jobs/trigger on weekday/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Purpose: To send notifications only on business days (Monday to Friday).

Verifies if the current day is a weekday (Monday to Friday).

Action on Valid Business Day:

Triggers a custom event:

Use Case:

Ideal for daily reminders, alerts, or updates that should not be sent on weekends
16 changes: 16 additions & 0 deletions Server-Side Components/Scheduled Jobs/trigger on weekday/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(function executeRule(current, previous) {
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek(); // Returns 1 (Monday) to 7 (Sunday)

// Check if it's a weekday (Monday to Friday)
if (dayOfWeek >= 1 && dayOfWeek <= 5) {

var grHoliday = new GlideRecord('cmn_schedule_holiday');
grHoliday.addQuery('date', today.getDate());
grHoliday.query();
if (!grHoliday.hasNext()) {
// Trigger notification
gs.eventQueue('<weekday>', current, '', '');
}
}
})(current, previous);
Loading