Google script trigger weekdays only
I had the same idea as Zig Mandel.
Instead of creating 1 trigger for each day, a simpler method is to stop the function if it is the week-end.
Set the trigger to Daily
and add few lines of code at the beginning of the function to do the trick:
function functionName(parameters) {
//Skip week-end
var day = new Date();
if (day.getDay()>5 || day.getDay()==0) {
return;
}
//Code to be executed
}
You can use the following function to create Triggers that will run every weekday at 11 AM.
function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY, ScriptApp.WeekDay.TUESDAY,
ScriptApp.WeekDay.WEDNESDAY, ScriptApp.WeekDay.THURSDAY,
ScriptApp.WeekDay.FRIDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger("your_function_name")
.timeBased().onWeekDay(days[i])
.atHour(11).create();
}
}
Run it daily and add an if at the beginning of your trigger using js functions to check for the day of week. getDay() method returns the day of the week (from 0 to 6)