AppsScriptPulse

Getting a Google Calendar event owner using Google Apps Script 

In the Google Group Apps Script community there was an interesting question about returning a Google Calendar event owner/organiser. The problem was that using the Calendar Service it is possible to use getGuestList(includeOwner) to return the EventGuest[] array and in theory using getGuestStatus() find the guest with the OWNER GuestStatus Enum:

const event = CalendarApp.getEventById('some_event_id');
const guestList = event.getGuestList(true); // get the guest list including owner  
// Iterate across EventGuest[]
for (let i = 0; i < guestList.length; i++){
  let guest = guestList[i].getEmail();
  let status = guestList[i].getGuestStatus().toString();
  Logger.log(guest + ' ' + status);
}

However, in practice as the organiser status defaults to ‘Yes’ and can change to ‘No’ or ‘Maybe’ the OWNER status is never returned:

How to solve? Well one solution to find the owner is to get the event guest list with and without the owner then filter out the list ignoring any accounts that appear twice:

  const event = CalendarApp.getEventById('some_event_id);
  const guestList = event.getGuestList(true); // get the guest list including owner
  const guestListWithoutOwner = event.getGuestList(); // get the guest list without the owner

  // filter the guest list to ingore duplicate emails leaving only the owner
  // based on https://stackoverflow.com/a/42995029/1027723
  const owner = guestList.filter(o1 => !guestListWithoutOwner.some(o2 => o1.getEmail() === o2.getEmail()));

  Logger.log('The owner is: ' + owner[0].getEmail());

Alternatively if the Calendar Advanced Service is enabled in your Apps Script project the owner email can be returned using:

  // With Calendar Advanced Service enabled
  // Note: eventId is different to the one returned by CalendarApp as it doesn't include @google.com
  // See https://stackoverflow.com/a/55545091/1027723 for how to handle 
  const event = Calendar.Events.get(CalendarApp.getDefaultCalendar().getId(), 'some_event_id');
  Logger.log('The owner is: ' + event.organizer.email); 

Clearly the second method is more direct, but which is quicker? I’ll let you tell me :)

Building a Google Calendar add-on and publishing it in the marketplace

Image credit: Gareth Cronin

I’ve long been interested in using one of the big office productivity platforms to build an embedded add-on. For a solo developer it’s a no-brainer: the platform takes care of the requirements above, and when the platform has a marketplace, there’s even a ready to go distribution channel to take it to market! The only real reason I’ve resisted it so far is fear of the slog of platform approval processes and required collateral. In this story I’ll explain how I felt the fear and did it anyway 😀

Google OAuth verification and Workspace Add-on app review can be quite daunting the first time you go through the process. In this post from Gareth Cronin he shares his own personal journey getting his JIT Time Google Calendar Add-on verified and approved. There are some great tips and resources shared in the post including how to show the  OAuth client ID in the add-on demo video submitted as part of the verification processes.

Source: Building a Google Calendar add-on and publishing it in the marketplace

How to create slot booking system using Google Apps Script and Google Calendar

Google Apps Scripts is incredibly powerful and enables complex systems to be built on top of Google Apps. It can be a great choice when you need to quickly prototype an idea or design a solution that’s customizable by non-technical users.

In this article, I will walk through a simple example of building a “Slot Booking System” using Google Sheets, Google Calendar, HTML, Tailwind CSS and Google Apps Script.

Nice little Apps Script project shared in this post using Google Calendar and a published web app, making it possibly a nice starter project for something bigger.

Source: How to create slot booking system using Google Apps Script and Google Calendar

Are the benefits of automation worth the overhead of setting things…

Image credit: Brightec

Why setting up automation is always worth it

As developers, we often find ourselves weighing up the benefits of automation against the overhead of setting things up. This is true for our personal workflows as well – I often have an idea of how I could automate various arduous tasks, but in reality, it’s difficult to justify doing so.

I ended up going with my gut on this one, and built a ‘calendar sync tool’ that automates the process. It turned out to be 100% worth it – and in this article, I’m going to argue that it’s always worth automating!

This post from Jonny Townend at Brightec is a two-for-one both highlighting the benefits of taking the time to automate workflows and as a bonus sharing a Google Apps Script powered Google Calendar sync tool.

Source: Are the benefits of automation worth the overhead of setting things…

Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script

This Google Apps Script allows you to create a Google Calendar event by sending yourself an email in Gmail. Unlike Gmail’s current feature to create Google Calendar events, this script allows you to be on a mobile device.

We’ve featured a couple of contributions from Al Chen in the past and this is another great one. For some context Al has also posted Productivity hack for creating a Google Calendar event by sending yourself an email. For the source code and setup follow the link at the end of the post. If you use Product Hunt and find this solution you can upvote here.

Source: GitHub – al-codaio/events-from-gmail: Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.

Create a Google Calendar Event via the Calendar API

Use the Calendar API to create an Event via Google Apps Script. Includes a tutorial video.

This is a simple Google Apps Script file that may look lengthy but in actual fact is just each possible item of an event that a user may wish to modify. Some of the items have default values which means you could remove them from the script and the Calendar API would use these defaults instead. My hope is that laying out the format like this allows you to then manipulate as you require and learn as I did.

Source: The Gift of Script: Create a Google Calendar Event via the Calendar API

Bulk create Google Calendar events with optional Meet or Zoom

Bulk create Google Calendar events with optional video conferencing (Google Meet or Zoom) all from a Google Sheet.

Google Sheet columns allow for event details to be added

Google Sheet columns allow for event details to be added

Features of the tool

  • Performs an initial check that you have access to the provided Calendar to create events on.
  • Allows for events to be created on another Calendar that you have suitable access to (not just your own).
  • Uses toast popups to inform you of the progress as each creates each event per row.
  • Fast and efficient for creating a large number of events in one go.
  • Will not duplicate events if re-run, so you can continue to append further if you wish.
  • Provides a direct link to the created event from within the Google Sheet for easy access.
  • Performs a check of any missing ‘required’ information and informs the user via a popup so they can resolve this.
  • Includes ‘Log’ sheet to help output any error messages.
  • Has a ‘Reset’ option in the menu bar to remove all entered data and start from scratch.
  • Replicates 90%+ of the settings you can adjust when directly creating an event in Google Calendar.

Source: The Gift of Script: Bulk create Google Calendar events with optional Meet or Zoom – overview

Bulk create Google Calendar events with optional Google Meet from a Google Sheet

Bulk create Google Calendar events with optional video conferencing (Google Meet) all from a Google Sheet.

Google Sheet columns allow for event details to be added

Google Sheet columns allow for event details to be added

Features of the tool

  • Performs an initial check that you have access to the provided Calendar to create events on.
  • Allows for events to be created on another Calendar that you have suitable access to (not just your own).
  • Uses toast popups to inform you of the progress as each creates each event per row.
  • Fast and efficient for creating a large number of events in one go.
  • Will not duplicate events if re-run, so you can continue to append further if you wish.
  • Provides a direct link to the created event from within the Google Sheet for easy access.
  • Performs a check of any missing ‘required’ information and informs the user via a popup so they can resolve this.
  • Includes ‘Log’ sheet to help output any error messages.
  • Has a ‘Reset’ option in the menu bar to remove all entered data and start from scratch.
  • Replicates 90%+ of the settings you can adjust when directly creating an event in Google Calendar.

Source: The Gift of Script: Bulk create Google Calendar events with optional Google Meet

Using Google Apps Script to schedule Google Meets for a Virtual Parents’ Evening Assistant

If your school is considering conducting an online ‘Virtual Parents’ Evening’ due to covid restrictions, this project might save your staff time. The Google Sheet (make a copy at https://bit.ly/vpeassistant ) uses Google Apps Scripts to automatically create a Calendar event (in your default Calendar), create a Meet link as part of the event, paste the Meet link back into the Sheet and create a draft email to the parent containing the Meet link and time/date.

A simple and effective solution from Luke Craig to help you manage virtual parents evenings … and more. In particular useful to see how you can add Google Meet video calls to you calendar invites. The video description also includes a link to the source code on Github.

Add a Google Meet to Calendar Events with Google Apps Script

My small team relies on automation to make things run. Part of our PD process is a Google Form workflow that kicks off calendar events, document creation, and email notifications. Since we’ve moved to online learning, we wanted to update that process to automatically add a Google Meet link for any PD that doesn’t have to be in person.

There are some official Google guides that show how to attach a Meet event to the Calendar, but nothing from the perspective of Apps Script specifically, so that’s what is shown here.

Source: Add a Google Meet to Calendar Events with Google Apps Script