a recent feature in Google Calendar allows users to select a working location (home, office, other) for every working day. Do you know if there is a way to retrieve this info using Apps Script ?
Thanks
Mathieu
a recent feature in Google Calendar allows users to select a working location (home, office, other) for every working day. Do you know if there is a way to retrieve this info using Apps Script ?
Thanks
Mathieu
This is currently not available to the API.
Here is a list of all the settings available to the API: Settings.
You can notice that many settings from https://calendar.google.com/calendar/u/0/r/settings are not available, including Enable working location
. Since this is a very recent feature, it's not strange that it hasn't yet been added to the API.
Another user suggested this feature to be implemented in the Calendar API. You can click on the star next to the issue number to give more priority to the request and to receive updates: https://issuetracker.google.com/199918380
There is actually now an API for doing this available in Developer Preview: https://developers.google.com/calendar/api/guides/working-hours-and-location
You can now do so with Google Apps Script:
Then, in the Google Apps Script, you can read the events with Calendar.Events.list
, make sure to pass eventTypes: ['workingLocation']
as optionalArgs
:
const calendarId = 'primary'
// Query parameters for the list request.
const optionalArgs = {
eventTypes: ['workingLocation'],
showDeleted: false,
singleEvents: true,
timeMax: '2023-07-10T00:00:00+01:00',
timeMin: '2023-06-27T00:00:00+01:00',
}
var response = Calendar.Events.list(calendarId, optionalArgs );
For more details, including a more fleshed out example (also for setting your work location), see the official documentation: https://developers.google.com/calendar/api/guides/working-hours-and-location
© 2022 - 2024 — McMap. All rights reserved.