1

I'm pretty new to Google-Apps-Script. Could you give an example how to use

Calendar > Recurrence > onlyOnWeeks

I want to create a daily event, but only in three specific weeks. My solution does not to work correctly. Daily events are creating but for every week.

var myrecurrence = CalendarApp.newRecurrence()
                          .addDailyRule().onlyOnWeeks([44,45,51]);
cal.createEventSeries(mytitle, startTime, endTime, myrecurrence);
Auberon Vacher
  • 4,655
  • 1
  • 24
  • 36
  • Perhaps you could make an attempt at this yourself and then post here if you encounter problems and ask for help with a specific issue? – Ren Nov 01 '12 at 09:58

1 Answers1

1

The CalendarApp API behind the scenes uses the iCal specification. Per the specification, the "onlyOnWeeks" rule can only be applied with yearly rules.

More here - http://www.ietf.org/rfc/rfc2445.txt

Search for "BYWEEKNO" and find the second instance for the specific rule there.

So try this line below and I think you'll get closer. Notice the "addYearlyRule" instead of "addDailyRule"

var myrecurrence = CalendarApp.newRecurrence().addYearlyRule().onlyOnWeeks([44,45,51]);
Arun Nagarajan
  • 5,547
  • 1
  • 22
  • 19