From e9623abe1a52a33f9f255d9e6ce68064a8904058 Mon Sep 17 00:00:00 2001 From: Shankha Bhattacharya <48099339+iamshankha@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:40:20 +0530 Subject: [PATCH 1/2] Create Adaptive_Scheduler.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adaptive Scheduler Purpose: Automates quarterly report scheduling by intelligently adjusting the run date based on weekends or Fridays. Business Logic: The report is configured to run monthly on the 5th day. The script checks if the 2nd day of the quarterly month (February, May, August, November) falls on a Friday or weekend. If the 2nd day falls on a Friday or weekend, the scheduled report will run on the 5th day instead. If the 2nd day is a regular business day, the report will already be sent on the 2nd day of that month. 💡 Benefit: ⏰ Minimizes manual intervention and ensures reports always run on valid business days — maintaining consistent quarterly reporting. Type: Server-side Script (Scheduled Report Condition) Run: Monthly Day: 5 --- .../Adaptive Scheduler/Adaptive_Scheduler.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Adaptive Scheduler/Adaptive_Scheduler.js diff --git a/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/Adaptive_Scheduler.js b/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/Adaptive_Scheduler.js new file mode 100644 index 0000000000..8831d82785 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/Adaptive_Scheduler.js @@ -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; From 5637db227c3c9cbb9310f10051992a7d4c76dc57 Mon Sep 17 00:00:00 2001 From: Shankha Bhattacharya <48099339+iamshankha@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:47:22 +0530 Subject: [PATCH 2/2] Create README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🗓️ 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 --- .../Adaptive Scheduler/README.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Adaptive Scheduler/README.md diff --git a/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/README.md b/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/README.md new file mode 100644 index 0000000000..8f9c66f6f8 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Adaptive Scheduler/README.md @@ -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