I'm developing a Google Calendar addon.
I want to be able to modify event fields (e.g. the title) within the addon.
I have a function that runs when triggered by eventOpenTrigger
.
According to the documentation, we can only addAttendees
and setConferenceData
. I tested those functions and they are working fine for both existing and new events.
Is there any proper way to modify other event fields?
I found a "dirty trick" to modify the event's title for an existing event using the CalendarApp API:
function onCalendarEventOpen(e) {
var calendar = CalendarApp.getCalendarById(e.calendar.calendarId);
var event = calendar.getEventById(e.calendar.id);
if (!event) {
// This is a new event still being created.
return createSimpleTextCard('A new event! Am I invited?');
}
event.setTitle('Modified title') // imagine doing this after a button click
return createSimpleTextCard('Modified title');
}
This trick has some drawbacks:
- The event page's ui that we are currently editing is not refreshing accordingly; we have to close/open the event to see the changes. Plus, if the user make any change on the modified fields, it keeps his version. Is there any way to force a "refresh" of those fields so that the user can see an up-to-date version of the event?
- It doesn't work with new events (for which we have no valid ID when querying the API) which would be very annoying for the addon I'm developing.
Does someone have a better solution? Am I missing something? It would be awesome to have a function setTitle
that works the same way as addAttendees
on a CalendarEventActionResponseBuilder
.