Complete the steps described in the rest of this page, and in about five minutes you'll have automatically created a Google Form based on data in a spreadsheet, then set it up to email Google Calendar invites and a personalized Google Doc to everyone who responds.
Set it up
- Make a copy of the sample spreadsheet Apps Script Quickstart: Managing responses for Google Forms.
- From within your new spreadsheet, select the menu item Tools > Script editor. If you are presented with a welcome screen, click Blank Project.
- Rename the
Code.gs
file toforms.gs
. Replace any code in the
forms.gs
file with the code below:
- Select the menu item File > Save. Name your new script and click OK.
Format dates and set locale
The sample spreadsheet uses the U.S. date format (mm/dd/yyyy). To ensure that the examples work correctly in your locale, you may need to:
- Select File > Spreadsheet settings.
- Set the correct locale and time zone. Click Save settings.
- Reformat the dates in the spreadsheet to your local format. For example, in the UK you should use dd/mm/yyyy.
Try it out
- Switch back to your spreadsheet and reload the page.
- After a few seconds, a new custom menu, Conference, will appear. Click it and select Set up conference.
- A dialog box will appear and tell you that the script requires authorization. Click Continue. A second dialog box will then request authorization for specific Google services. Read the notice carefully, then click Allow.
- The script will take a few seconds to run. You'll know it's complete when the yellow bar at the top of the screen disappears.
- The Conference menu will now be gone, but you will see a new Form menu instead. Click it and select Go to live form.
- Fill out the form to indicate which sessions you'd like to attend at this fictional conference. If you have more than one Google account, use a different email address for this form than the account you used to create the script. (You don't need to log in to the second account; just type in the email address at the top.) When you're done, click Submit.
See the results
- Open your Google Calendar and navigate to the conference dates: May 15 and 16, 2013. You'll see an event for each session. If you used a different email address when you responded to the form, that address will have been invited as a guest for the sessions you selected.
- Open your Google Drive. You'll see a new Google Doc that lists the sessions you selected. If you used a different email address when you responded to the form, that address will be listed as an editor. Users other than the script owner will find a copy of the document in their Shared with me view.
- Try sharing the link to the form with other people. As they respond, you'll see the Google Calendar invites and Google Doc itineraries start to add up. If you were organizing a real conference, think about how much time this would save!
That's it! With only a small amount of code, you've added a custom menu item, programmatically built a Google Form, created Google Calendar events, and told a script to send Calendar invites and personalized Google Docs on your behalf.
Learn more
To continue learning about how to extend Google Forms, Calendar, and Docs with Apps Script, take a look at the following resources: