Skip to content

Commit ac2d8b0

Browse files
authored
Code snippet - Checking Specific Day and Execute Logic (#1697)
* creation of Do Task on weekdays Code that verifies today is weekend or not. If today is not weekend, system can trigger mails or execute scripts or do some other updates based on current data. * Create README.md Script for checking today is weekday and execute or trigger next part. * creation of Do Task on weekdays Check if today is weekday and execute the task to be executed everyday except Saturday and Sunday. * Rename Do Task on weekdays to Do Task on weekdays.js * Update Do Task on weekdays.js * Update README.md * Rename Do Task on weekdays.js to doTaskonWeekdays.js * Update README.md
1 parent 2aa679b commit ac2d8b0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Background Script that checks today is weekday and then execute further logic inside if block.
2+
This script can also be used in 'Condition' part of Scheduled job, with an answer variable.
3+
4+
var answer = false;
5+
Code snippet{ inside if condition, set answer = true; }
6+
answer;
7+
8+
This will ensure Scheduled Script only executes on Weekdays.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//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.
2+
3+
var today = new GlideDateTime();
4+
var day = today.getDayOfWeek(); //returns the day of week as number, Monday = 1, Tuesday = 2, ... Saturday = 6, Sunday = 7
5+
if(day != 6 && day != 7){
6+
//Do whatever task or update you want to execute on weekdays be it triggering emails or running scheduled script
7+
gs.print("Today is weekday. Good to execute updates.");
8+
}

0 commit comments

Comments
 (0)