diff --git a/Server-Side Components/Background Scripts/Execute Logic on Weekdays/README.md b/Server-Side Components/Background Scripts/Execute Logic on Weekdays/README.md new file mode 100644 index 0000000000..a24e7f7596 --- /dev/null +++ b/Server-Side Components/Background Scripts/Execute Logic on Weekdays/README.md @@ -0,0 +1,8 @@ +Background Script that checks today is weekday and then execute further logic inside if block. +This script can also be used in 'Condition' part of Scheduled job, with an answer variable. + +var answer = false; +Code snippet{ inside if condition, set answer = true; } +answer; + +This will ensure Scheduled Script only executes on Weekdays. diff --git a/Server-Side Components/Background Scripts/Execute Logic on Weekdays/doTaskonWeekdays.js b/Server-Side Components/Background Scripts/Execute Logic on Weekdays/doTaskonWeekdays.js new file mode 100644 index 0000000000..c4686ff65a --- /dev/null +++ b/Server-Side Components/Background Scripts/Execute Logic on Weekdays/doTaskonWeekdays.js @@ -0,0 +1,8 @@ +//Code that checks if today is not Saturday or Sunday (i.e. Weekend) and if it turns out that today is not weekend, then execute the further logic written. + +var today = new GlideDateTime(); +var day = today.getDayOfWeek(); //returns the day of week as number, Monday = 1, Tuesday = 2, ... Saturday = 6, Sunday = 7 +if(day != 6 && day != 7){ + //Do whatever task or update you want to execute on weekdays be it triggering emails or running scheduled script + gs.print("Today is weekday. Good to execute updates."); +}