user2045012
user2045012

Reputation: 11

google apps script I want to define a recurrence for all months first saturday

I have a problem with recurrence. I'm not able to define a recurrence for all months, only the first saturday

I have this code:

var bck_startdate = new Date("January 7, 2012 22:00"); 
var bck_enddate = new Date("January 7, 2012 23:00"); 
eventRecurrence.addMonthlyRule().onlyOnWeekday(CalendarApp.Weekday.SATURDAY);
var cal_event=cal_netbackup.createEventSeries("TEST,bck_startdate,bck_enddate,eventRecurrence,{description:"TEST_DESCRPT"});

But the result is all weeks on saturday. If I enter on eventserie directly on calendar and I press weekday it works fine.

Upvotes: 1

Views: 379

Answers (1)

Eric Koleda
Eric Koleda

Reputation: 12671

You can ensure it's only the first Saturday of the month by limiting the days of the month to the first seven.

var recurrence = CalendarApp.newRecurrence().addMonthlyRule()
    .onlyOnWeekday(CalendarApp.Weekday.SATURDAY)
    .onlyOnMonthDays([1,2,3,4,5,6,7]);

Upvotes: 1

Related Questions