I created a recurring series using Google-calendar-api from December 11 to December 20. I made a change (For eg: Description) of a single instance on December 18th using "this event" only option.
Then I'm editing the title on December 15 and choosing "This and following" options. This resets my exception on December 18th (where the description was changed) to match the December 15th description.
How to persist the exceptions of the series when splitting the parent series into two for 'this and following' as mentioned in the Google API docs.
Edit: To create Google recurring event:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $timezone
],
'conferenceData' => $conference_link,
]);
$event>setRecurrence(array(format_recurrence_rule_for_google($recurrence_pattern)));
// set Google calendar event parameters.
$calendar_id = 'primary';
$opt_params = [
'sendNotifications' => $send_invite,
'conferenceDataVersion' => 1
];
// create the Google calendar event
$event = $service->events->insert($calendar_id, $event, $opt_params);
To update a single instance:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $meet_creator->timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $meet_creator->timezone
],
"recurringEventId" => $recurring_event_id,
"originalStartTime" => [
"dateTime" => $exist_event->getOriginalStartTime()->getDateTime(),
"timeZone" => $meet_creator->timezone
],
"iCalUID" => $exist_event->getiCalUID(),
'conferenceData' => event_conference($meeting->conference)
]);
$opt_params = [
'conferenceDataVersion' => ($generate_conf || $cancel_conf) ? 1 : 0
];
$calendar_id = 'primary';
$updatedEvent = $service->events->insert($calendar_id, $event, $opt_params);
This and following events code snippet
$current_event = $this->get_instance_with_event_id($parent_meeting);
$rec = format_recurrence_rule_for_google($parent_meeting->meeting_options->recurrence);
$current_event->setRecurrence(array($rec));
// trim the parent recurring event into two
$service->events->update('primary', $parent_meeting->meeting_options->recurring_event_id, $current_event);
$event = $this->create_initial_calendar_event() // which is the first snippet to create recurring event
It is not possible
The official documentation explains how to work with Recurring Events. It has a section that shows how to modify all following instances but following these steps you get two separated Recurring Events
and the exception instances
will disappear. There is only one way of modifying some parameters of an instance
and apply them to this and following events and that is using the web version of the Calendar
(it also respects the exceptions).
Looping
Update and Insert (check the official documentation here)
Recurring Event
with the recurrence
modified to cover the desired days.Recurring Events
and the Event resources
had to be defined from zero. It also overlaps the exceptions.Get, Patch and Insert (can handle some exceptions)
Recurring Event
with all its information.instances
that have the exceptions
. The body request is an Event resource that can be the defined in two ways:
start
, end
and recurrence
. Using patch
maintains all the other parameters.get
. In your case, you need to modify start.dateTime
and end.dateTime
to December 15 (and corresponding hours) and the new parameter that you want to change, for example the description
.exceptions
. The Event resource
used in this step is a clone from the original Recurring Event
. There are some properties that need to change: iCalUID = ""
, id = ""
, and for your case the recurrence
in order to stop on December 15.Recurring Events
and takes three different API calls. The exceptions
are only maintained in one Recurring Event
.Cancel instance, insert new event
instances
of a Recurring Event
.Recurring Event
changing its status
: Cancelled exceptions of an uncancelled recurring Event indicate that this instance should no longer be presented to the user.Event resource
on the same date as the cancelled instance
so that future changes to the Recurring Event
do not change this exception
. The properties can be obtained from the original instance
.Recurring Event
.