Coding level: Beginner
Duration: 5 minutes
Project type: Automation with a custom menu and
an event-driven trigger
Objectives
- Understand what the solution does.
- Understand what the Apps Script services do within the solution.
- Set up the script.
- Run the script.
About this solution
Create an end-to-end event registration system. If you have an event coming up, like a conference, you can set up a new calendar for conference sessions, create a sign-up form, and automatically email attendees personalized itineraries.
How it works
This solution uses a custom menu in Google Sheets to implement an automated event registration system. The script creates a calendar with the conference events listed in the Sheets spreadsheet. Then, the script creates a form with the list of events that attendees can sign up for. After attendees fill out the form, the script adds the attendees to the calendar events and emails itineraries to them.
Apps Script services
This solution uses the following services:
- Spreadsheet service–Provides the event information to the other services.
- Calendar service–Creates a new calendar for the event, adds events to the calendar, and adds attendees to the events they sign up for.
- Properties service–Stores the ID of the calendar created by the Calendar service. When a user clicks Set up conference from the custom Conference menu, the Properties service checks whether the event registration system has already been set up by checking if the calendar ID property is present. Doing so helps avoid the creation of duplicate forms and calendars.
- Forms service–Creates a form from the information in the spreadsheet that lets attendees sign up for sessions.
- Script service–Creates a trigger that fires when an attendee fills out the form.
- Document service–Gets the event information for the events an attendee signs up for and adds a list of the events to a new document. The script gives the attendee permission to edit the document.
- Mail service–Emails the itinerary document to the attendee.
Prerequisites
To use this sample, you need the following prerequisites:
- A Google Account (Google Workspace accounts might require administrator approval).
- A web browser with access to the internet.
Set up the script
- Click the following button to make a copy of the Create a sign-up for
sessions at a conference sample spreadsheet. The Apps Script
project for this solution is attached to the spreadsheet.
Make a copy - Click Conference > Set up conference. You might need to refresh the page for this custom menu to appear.
When prompted, authorize the script. If the OAuth consent screen displays the warning, This app isn't verified, continue by selecting Advanced > Go to {Project Name} (unsafe).
Click Conference > Set up conference again.
Run the script
- Click Tools > Manage Form > Go to live form.
- Fill out and submit the form.
- Go to calendar.google.com.
- At the left, make sure the box next to Conference Calendar is checked.
- Go to the dates of the events you signed up for and confirm you've been added as an attendee.
(Optional) Reset the solution
If you want to try this solution over again, or customize it to use your own event information, you need to reset some items that were set up when you first ran the script. To view the steps to reset the solution, click Reset the solution below:
Reset the solution
Step 1: Reset the stored script properties
If you try to run the script more than once, you'll be prompted with, Your conference is already set up. Look in Google Drive for your sign-up form! This happens because once the Conference Calendar is created, the calendar ID is stored as a script property. When the script runs, it checks if the calendar ID property already exists, and stops running if it does.
Follow the below steps to remove the existing calendar ID property:
- In the spreadsheet, click Extensions > Apps Script.
- In the Apps Script editor, select
resetProperties
from the function dropdown list and click Run.
Step 2: Delete the Conference Calendar
Every time the script runs, it creates a new calendar. If you don't want to keep the original calendar that was created, follow these steps:
- Go to calendar.google.com.
- Next to Conference Calendar, click Options for Conference Calendar > Settings and sharing.
- Scroll to the bottom of the settings and click Delete.
Step 3: Delete the form submit trigger
The script creates a trigger for form submissions each time you run it. To avoid multiple triggers that result in duplicate emails, remove the original trigger. Follow these steps:
- In the spreadsheet, click Extensions > Apps Script.
- In the Apps Script project, at the left, click Triggers .
- Next to the trigger, click More > Delete trigger.
Step 4: Unlink and delete the form
Each time you run the script, it creates a new form. Follow these steps to unlink the form from your spreadsheet and delete it:
- In the spreadsheet, right click the Form responses sheet and click Unlink form > Ok.
- Right click the Form responses sheet again and click Delete > Ok.
- Go to forms.google.com.
- Right click Conference Form and click Remove > Move to trash.
Once you've reset the solution you can add your own data, or continue to use the sample data, and run the script again.
Review the code
To review the Apps Script code for this solution, click View source code below:
View source code
Code.gs
Contributors
This sample is maintained by Google with the help of Google Developer Experts.