Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*Adaptive-Scheduler
--------------------------------------------------------------
- This script is intended to be added to the *Condition* field
of a Scheduled Report.
- Ensure the *"Advanced"* option checkbox is checked.
- Purpose:
* Run quarterly reports on the 2nd day of the quarter.
* If the 2nd day falls on a Friday, Saturday, or Sunday,
the report will instead run on the 5th day.
- Benefits:
* Ensures consistent quarterly reporting.
* Eliminates manual rescheduling for weekend conflicts.
* Maintains timely delivery of business insights.
-------------------------------------------------------------------------
- Scheduled Report configuration
* Run: Monthly
* Day: 5
-------------------------------------------------------------------------
*/




var start = false; //flag is declared
var gdt = new GlideDateTime(); // Create a GlideDateTime object for date calculations
gdt.addDays(-3); // Move back 3 days to simulate checking the 2nd day’s conditions
var dayOfWeek = gdt.getDayOfWeek(); // Get the day of the week (1 = Monday, 7 = Sunday)
var currentMonth = gdt.getMonthLocalTime();

if (((currentMonth % 3) == 2) && (dayOfWeek == '5' || dayOfWeek == '6' || dayOfWeek == '7')) { // Check if this is a quarterly month (February, May, August, November)
// if the 2nd day falls on a Friday (5), Saturday (6), or Sunday (7)
start = true; // Run on 5th if 2nd is Friday/weekend
}
start;
30 changes: 30 additions & 0 deletions Server-Side Components/Scheduled Jobs/Adaptive Scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
πŸ—“οΈ Adaptive Scheduler

πŸ“˜ Overview

The Smart Quarterly Scheduler automates report execution for quarterly business reviews. It ensures that scheduled reports never fall on weekends or Fridays, maintaining consistent and reliable delivery.

🧩 Problem Statement

The business requires a quarterly report to run on the 2nd day of specific months (February, May, August, and November). However, when the 2nd day falls on a Friday or weekend, the client team will be typically on leave and may miss reviewing urgent reports.
This results in communication delays and missed insights during critical business periods.

πŸ’‘ Solution

This script dynamically checks whether the 2nd day of the quarterly month is a Friday or weekend:

If yes β†’ the report automatically runs on the 5th day.

If no β†’ the report runs as usual on the 2nd day through another Scheduled Report.

It uses GlideDateTime logic to determine execution dynamically within the Scheduled Report Condition.

πŸš€ Benefits

⏰ Minimizes manual scheduling effort

βœ… Ensures reports always run on valid business days

πŸ“Š Maintains consistent quarterly performance insights

πŸ” Completely automated logic without admin dependency
Loading