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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to France

Premium delivery 7 - 10 business days

€10.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to France

Premium delivery 7 - 10 business days

€10.95
(Includes tracking information)

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
€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

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela