I can make this example example work. What I need is to set the weekday from a cell in column "weekday".
I have tried this:
if(type=='PD'){
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(weekday);
event.setRecurrence(recurrence, tstart, tstop);
}else
...where weekday refers to column "weekday".
What am I doing wrong in my own version?
I could confirm that from your script and shared Spreadsheet, the values of NewWeekday
are WEDNESDAY
and MONDAY
of the string type. In this case, how about the following modification?
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(weekday);
event.setRecurrence(recurrence, tstart, tstop);
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(CalendarApp.Weekday[NewWeekday]); // Modified
event.setRecurrence(recurrence, tstart, tstop);
If I misunderstood your question and this was not the result you want, I apologize.
tstop
as "until".For this, how about the following modification?
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(weekday);
event.setRecurrence(recurrence, tstart, tstop);
var recurrence = CalendarApp.newRecurrence().addWeeklyRule().onlyOnWeekday(CalendarApp.Weekday[NewWeekday]).until(tstop); // Modified
event.setRecurrence(recurrence, tstart); // Modified