This document discusses automating Google Forms using Apps Script. It provides an overview of Apps Script and how it can be used to automate Forms through the Forms Service. It then shares a sample JavaScript application that demonstrates programmatically creating a Form with different field types like text, paragraphs, checkboxes and radio buttons. It concludes by listing several references for learning more about Apps Script and automating Forms.
2. About the speaker
● Mission: enable current AND FUTURE developers to be successful using
Google Cloud and other Google developer tools, APIs, and platforms
● Videos: host of the G Suite Dev Show on YouTube (goo.gl/JpBQ40)
● Blogs: developers.googleblog.com & gsuite-developers.googleblog.com
● Twitters: @wescpy, @GCPcloud, @GoogleDevs, @GSuiteDevs
● Background
○ Software engineer & architect for 20+ years
○ One of the original Yahoo!Mail engineers
○ Author of "Core Python" books (corepython.com )
○ Teacher & technical instructor since 1983 (all ages)
○ Fellow of the Python Software Foundation
○ Adjunct CS Faculty, Foothill College (Silicon Valley)
○ AB Mathematics & CMP Music, UC Berkeley; MSCS UC Santa Barbara
Agenda
● Forms automation: what & why
● Coding with Forms
● Sample application (JS)
● References
3. Google Forms automation: the what & the why
● Creating invidual Forms... no problem
● Making Forms on a regular basis? Also okay.
● How about 100s or 1000s of Forms regularly? Nope.
Coding with Google Forms
● There is no Google Forms HTTP-based REST API, but...
● Google does provide an "API" via Google Apps Script
● Apps Script: customized version of JS that...
○ Let's you automate, extend, and integrate w/G Suite and...
○ Many other Google tools (Maps, Analytics, YT, Translate, GCP)
○ Can automate with Apps Script Forms Service
4. Sample application (JS)
function createForm() {
// create & name Form
var item = "Speaker Information Form";
var form = FormApp.create(item)
.setTitle(item);
// single line text field
item = "Name, Title, Organization";
form.addTextItem()
.setTitle(item)
.setRequired(true);
Sample application (cont.)
// multi-line "text area"
item = "Short biography (4-6 sentences)";
form.addParagraphTextItem().setTitle(item)
.setRequired(true);
// radiobuttons
item = "Handout format";
var choices = ["1-Pager", "Stapled", "Soft copy (PDF)",
"none"];
form.addMultipleChoiceItem().setTitle(item)
.setChoiceValues(choices)
.setRequired(true);
5. Sample application (cont.)
// (multiple choice) checkboxes
item = "Microphone preference (if any)";
choices = ["wireless/lapel", "handheld", "podium/stand"];
form.addCheckboxItem()
.setTitle(item)
.setChoiceValues(choices);
}
References
● Forms blog post, video, code
○ goo.gl/EK5edG
● Google Apps Script documentation
○ developers.google.com/apps-script
● Forms Service Script documentation
○ developers.google.com/apps-script/reference/forms
● More Apps Script videos
○ developers.google.com/apps-script/guides/videos
● Apps Script introductory codelab
○ g.co/codelabs/apps-script-intro
6. More references
● G Suite developer overviews & platform video
○ developers.google.com/gsuite
● Markdown-to-Google Slides generator code repo
○ github.com/gsuitedevs/md2googleslides
● Flubaroo (grade Forms-based Sheets exams; sequel to GFormIt)
○ flubaroo.com
● GFormIt Docs Add-on (build Forms exams from Docs)
○ chrome.google.com/webstore/detail/pjjcjgmiefkilipggmepmjkndjaiijdb
● Contact
○ @wescpy a.k.a. twitter.com/wescpy
Questions?
goo.gl/Rq6ABI