Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Google Apps Script for Beginners
Google Apps Script for Beginners

Google Apps Script for Beginners: Building on your basic JavaScript knowledge, this book takes you into the world of Google Apps Script and shows you how to develop and customize your own apps. The step-by-step approach provides all the necessary skills.

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Google Apps Script for Beginners

Chapter 2. Create and Manipulate Forms

In January 2013, Google launched a new version of Google forms that was more customizable, richer in many new features, shareable between any number of editors, and—even more important to us—could be created and modified using Google Apps Script.

This feature made it possible to imagine a lot of potential applications. Some of these applications could be used for the following:

  • To change questions every day, automatically

  • To modify the form for future respondents based on responses from the past

  • To remove or add questions depending on any external parameter (such as the day of the week or the time of day)

What tools do we have?


The forms service has quite a lot of methods presented in the Google documentation, but some of the aspects of form creation and modification are still a bit complex to apprehend (https://developers.google.com/apps-script/reference/forms/).

To create a form, we only need a script in a project. This project can either be bound to a document or can be a standalone file in your drive.

Since the script actually creates a new form and a new spreadsheet to get responses from, we have no special interest in using a spreadsheet-bounded script or a form-bounded one. The following code creates a simple form; its contents are directly inspired by the example that Google provides in its documentation. We will see what we can do with it using only script. It will be an opportunity to see how we can change the form content and presentation (read the comments if you're not sure how it works).

// Global variable = constants
var ssId = ScriptProperties.getProperty('ssId');
if(ssId ==...

Forms' limitations


There are a few things we cannot achieve with FormApp. For example, there is no way to catch user response and modify a form according to their answers. The only form-related event that we can catch is the form submission itself; that is, we can catch the occurrence of an event when the form is submitted and all the data is already recorded. It's a major limitation of this service, but we'll see that it's possible to do so using other approaches.

Handling answers


The function we wrote in the script earlier will not be very useful if we have to run it manually (we won't be there to monitor every time someone fills a form). So, we should capture the event when someone sends a form so that we are informed by an e-mail message.

We already see the events available in the spreadsheet, so we know how it works. Just go to the Resources menu in the script editor to set up a new trigger On form submit as shown in the following screenshot:

Now the script will send us a message every time a form is filled. Note that the sidebar UI won't be updated since it can only work in cases where a user actually uses the form editor UI.

Forms' alternatives


If you need to customize your forms further than what Google's forms service offers or if you don't like to see Google's messages and logo on all the forms you send (these are indeed quite obvious), Google Apps Script has two UI-oriented services you can use. Both are capable of developing very complex UIs, the second being even more powerful as it includes the possibility to use external JavaScript libraries, such as jQuery.

A quick peek at the UiApp and HTML services


We saw in the previous form example that we can create small user interfaces to enhance the standard form UI. This is also available in documents and spreadsheets, although it is slightly different. I decided to use both of them in this small example to encourage you to experiment and customize more because, even if it takes some time to develop these tools, it is so rewarding from a personal point of view that it's well worth the pain.

UiApp was the first service available in Google Apps Script a few years ago and is still presented as experimental in the documentation, although no announcement has been made (for now) that they will deprecate it in the near future. Google encourages users to switch to an HTML service as this one will continue to be upgraded.

In the meantime, we will continue to show both of them as they both have strengths and weaknesses.

Summary


A forms service can actually be very useful to teachers or other people who need to create lots of forms or questionnaires, often using the same structure.

The ability forms have to respond to triggers provides the possibility to automatically send back an evaluation with reference to good and bad answers.

The academic community is probably the group most interested in this Google app.

It gives us the opportunity to use function parameters to split our code into smaller and simpler parts.

Our last example introduced the key word of the next chapter: e-mail.

Left arrow icon Right arrow icon

What you will learn

  • Get acquainted with the tools you have at hand
  • Exchange and communicate information between Google services
  • Build a private website using your private files
  • Construct a web app that really helps you at work
  • Solve common issues when using shared documents
  • Embed scripts and text documents in Google sites
  • Know where to find the information you will need to go further

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 21, 2014
Length: 178 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552184
Vendor :
Google
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Feb 21, 2014
Length: 178 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552184
Vendor :
Google
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 94.97
Google Apps Script for Beginners
€24.99
Google Maps JavaScript API Cookbook
€36.99
Learning Google Apps Script
€32.99
Total 94.97 Stars icon
Banner background image

Table of Contents

9 Chapters
Enhancing Spreadsheets Chevron down icon Chevron up icon
Create and Manipulate Forms Chevron down icon Chevron up icon
Managing an E-mail Account Chevron down icon Chevron up icon
Embedding Scripts in Text Documents Chevron down icon Chevron up icon
Embedding Scripts in Google Sites Chevron down icon Chevron up icon
Standalone Web Applications / User Interfaces Chevron down icon Chevron up icon
Using User Interfaces in Spreadsheets and Documents Chevron down icon Chevron up icon
How to Expand your Knowledge Chevron down icon Chevron up icon
Conclusion Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(15 Ratings)
5 star 40%
4 star 13.3%
3 star 20%
2 star 13.3%
1 star 13.3%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Jul 08, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent
Amazon Verified review Amazon
Jonathon Broughton Feb 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Serge is an active contributor to the community of Google Apps Script enthusiasts and a heavy hitter on Stack Overflow. This book reflects that activity and expertise.
Amazon Verified review Amazon
A.A. Jan 18, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great place to start. You won't get all the details, and most of the time there are no "whys", but it should get you started.Pros:Lots of examples on what can be done, it's up to you to apply the knowledge.Cons:Not enough background or foundation. It just goes on and on, if you need programming basics start somewhere else.
Amazon Verified review Amazon
David Fulmer Sep 01, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I only read chapters 1, 8, and 9 of this book, because I was only interested in using Google Apps Script for working with Google spreadsheets, but I wanted to leave a review of the book because I found it to be excellent. I really enjoyed the author’s tone and enthusiasm and found this to be an excellent tutorial. The book is a few years old by now (2023) but all the examples of code from the book that I tested worked pretty much perfectly. The book was written at the time (December 2013) of some major changes to the Google Apps Script platform and the author does note that. Additionally, there have been some major changes since the book was published, especially to the IDE in December 2020, but again, I still found this a great tutorial with many working examples and no major problems resulting from the evolution of the platform. The author even mentions some of the changes that were happening around 2013 and offers alternative code in the book. One last thing I loved about the book: the author is really motivated to teach people and he writes a great pep talk for the reader encouraging learning and outlining how to go from a novice to an expert and how to keep learning. In addition to the practical hands-on examples, I really appreciated this feature of the book and wish more programming textbooks were like this.
Amazon Verified review Amazon
Angelo Feb 23, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Google Apps Script platform allows novice programmers (and even amateurs like me!) build powerful applications. Anyone who uses this platform and attends the stackoverflow forum inevitably have come across this author, because Serge Insas have answered (with lots of patience sometimes) hundreds or thousands of questions from users of that forum. So it is with great joy that I got the news that he has consolidated knowledge he gained answering all those questions in a book. I wrote this review basing myself on the quality of answers in stackoverflow from Sergei Insas ([...]). As soon as I finish reading the book, I will edit this review in greater detail.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.