Auto-generating Google Forms

JUN 06, 2016

Posted by Wesley Chun (@wescpy), Developer Advocate, Google Apps

 function createForm()
      // create & name Form
      var item = "Speaker Information Form";
      var form = FormApp.create(item)

      // single line text field
      item = "Name, Title, Organization";

      // multi-line "text area"
      item = "Short biography (4-6 sentences)";

      // radiobuttons
      item = "Handout format";
      var choices = ["1-Pager", "Stapled", "Soft copy (PDF)", "none"];

      // (multiple choice) checkboxes
      item = "Microphone preference (if any)";
      choices = ["wireless/lapel", "handheld", "podium/stand"];

If you’re ready to get started, you can find more information, including another intro code sample, in the Google Forms reference section of the Apps Script docs. In the video, I challenge viewers to enhance the code snippet above to read in “forms data” from an outside source such as a Google Sheet, Google Doc, or even an external database (accessible via Apps Script’s JDBC Service) to generate multiple Forms with. What are other things you can do with Forms?

One example is illustrated by this Google Docs add-on I created for users to auto-generate Google Forms from a formatted Google Doc. If you’re looking to do integration with a variety of Google services, check out this advanced Forms quickstart that uses Google Sheets, Docs, Calendar, and Gmail! Finally, Apps Script also powers add-ons for Google Forms. To learn how to write those, check out this Forms add-on quickstart.

We hope the DevByte and all these examples inspire you to create awesome tools with Google Forms, and taking the manual creation burden off your shoulders! If you’re new to the Launchpad Online developer series, we share technical content aimed at novice Google developers, as well as discuss the latest tools and features to help you build your app. Please subscribe to our channel, give us your feedback below, and tell us what topics you would like to see in future episodes!