Reputation: 45
Goal: Add attendees through Google Calendar Add on to live event being created on the spot
Context: Live Event being created (left)+ Calendar Add on (Right)
Code snip:
current_user = e.calendar.calendarId;
event_id = e.calendar.id;
var calendar = CalendarApp.getCalendarById(current_user);
var event = calendar.getEventById(event_id);
However, when I open an event, and current_user
and event_id
have values, event
seems to be null
, because this event is not technically 'created' yet. If it were created yet, then a simple event.addGuest()
would work
Is it even possible to customize a live event while it is being created? Every example I find only updates events already created.
Edit: Forgot to post scopes I am using. Snippet of appsscript.json is below
{
....,
"oauthScopes": [
"https://www.googleapis.com/auth/calendar.addons.current.event.read",
"https://www.googleapis.com/auth/calendar.addons.current.event.write",
"https://www.googleapis.com/auth/calendar.addons.execute",
"https://www.googleapis.com/auth/script.external_request",
"https://www.google.com/calendar/feeds"
],
"addOns": {
"common": {
...
}
},
"calendar": {
"currentEventAccess": "READ_WRITE",
...
}
}
}
Upvotes: 2
Views: 430
Reputation: 31300
Change your code to:
if (!e.calendar.capabilities.canAddAttendees) {
return;
}
CardService.newCalendarEventActionResponseBuilder()
.addAttendees(["[email protected]", "[email protected]"])
.build();
See documentation at:
https://developers.google.com/workspace/add-ons/calendar/calendar-actions?hl=en#adding_attendees_with_a_callback_function
Upvotes: 2