O'Reilly logo

Google Script: Enterprise Application Essentials by James Ferreira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Mash Up

Directing Email Using Google Forms

Google Forms are a very convenient way to quickly get information into a spreadsheet. Add some Google Script and you can turbo charge that form to send email notifications, generate other data in the spreadsheet, and all those things you might want to do when getting data from a form.

In this section you will learn the basics of getting form information into a Google Script and sending an email depending on a selection from a drop down list in the Google form.

Highlights:

  • Google Forms

  • EmailApp

  • Event Triggers

Open up a Google spreadsheet and start creating a form. The example we will use is for routing inquiries to the right department: Sales or Service. Figure 9-1 shows the form editor and the drop down box selection.

Google forms can be inserted into most websites and emailed
Figure 9-1. Google forms can be inserted into most websites and emailed

After creating the form you can return to the spreadsheet to see the form fields have become columns in the spreadsheet. See Figure 9-2.

Note the timestamp is automatically added
Figure 9-2. Note the timestamp is automatically added

Now open the Script Editor (Tools➝Script editor).

You can delete the default function and start the script with global variables (outside any function) that will contain the email addresses for the correct department.

var sales = 'sales@example.com'; var service = 'service@example.com'; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required