Reputation: 5795
I looked at Mogsdad's answer to a sort-of-similar question here, but it's not incredibly specific to my problem. I've also looked at the documentation for the Calendar class and its subclasses, but there is no method (which should be implemented in my opinion; there is a pending feature request) for copying a single event from Calendar X to Calendar Y.
What I want to do is as follows:
The only way I could think of how to do it is sloppy (semi-pseudo below):
// y is Calendar Y, z is the ID of Event Z
function moveToNewCalendar(y, z) {
var eventToMove = getEventByID(z);
// eventDetails is an Object
var eventDetails = getAllEventDetails(eventToMove); // This is not fun!
y.createEvent(eventDetails);
eventToMove.deleteEvent();
}
function getAllEventDetails(e) {
var details = {};
details["title"] = e.getTitle();
details["startTime"] = e.getStartTime();
// ... etc
return details;
}
function createEvent(eventDetails) {
// Create event using the information pulled from eventDetails
}
This functionality is available through the Google Calendar API v3 - move function, but not through GAS.
I suppose that the main problem is copying the details of the event. There is no function to createEvent(Event e)
in the Calendar prototype. Is there an easier way to do this that I'm just missing?
Upvotes: 2
Views: 2746
Reputation: 46794
This new library written by Romain Vialard will give you a complete solution... I had the pleasure to be a beta tester and all my tests were successful :-)
Upvotes: 1