Reputation: 631
I'm trying to write a Google script that will move from one calendar (pubCal) all events within a given time frame to another calendar (privCal).
I'm not sure why, but the code breaks at the line: "Calendar.Events.move(pubCalId, eventToMove.getId(), privCalId);", with the error message: "Not Found (line 18, file "Code")"
What does this error message mean?
function export_gcal_to_gsheet(){
//pubCall: public calendar
//privCal private calendar
var pubCalId = "[email protected]";
var privCalId = "[email protected]";
var pubCal = CalendarApp.getCalendarById(pubCalId);
//Change date range to move events from pubCal to privCal
var startDate = "January 1, 2018 00:00:00 CST";
var endDate = "January 04, 2018 23:59:59 CST";
// Extract events between certain dates in public calendar.
var events = pubCal.getEvents(new Date(startDate), new Date(endDate));
//Loop through all Calendar events
while (events.length > 0){
var eventToMove = events.shift();
Calendar.Events.move(pubCalId, eventToMove.getId(), privCalId);
}
}
Upvotes: 1
Views: 982
Reputation: 201378
How about the following modification?
Calendar.Events.move(pubCalId, eventToMove.getId(), privCalId);
Calendar.Events.move(pubCalId, eventToMove.getId().replace("@google.com", ""), privCalId);
eventToMove.getId()
is #####@google.com
. But the id which is used for Calendar.Events.move()
is #####
. So @google.com
is required to be removed from #####@google.com
.
#####@google.com
cannot be found, the error occurs.If I misunderstand your question, I'm sorry.
Upvotes: 2