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
₹799.99 ₹1965.99
Paperback
₹2457.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with a Packt Subscription?

Free for first 7 days. ₹800 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781783552177
Vendor :
Google
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. ₹800 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 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
₹4500 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 ₹400 each
Feature tick icon Exclusive print discounts
₹5000 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 ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 9,384.97
Google Apps Script for Beginners
₹2457.99
Google Maps JavaScript API Cookbook
₹3649.99
Learning Google Apps Script
₹3276.99
Total 9,384.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.