AppsScriptPulse

Manage Google Form onFormSubmit script executions with Script Lock

Use the Apps Script Lock Service to control Form submissions and prevent data loss

Lock Service code snippet

Lock Service code snippet

The following Google Apps Script is a one example of how the Lock Service can be used to prevent concurrent running of code. Here we have a Google Form that can be submitted by users at any point, the code then takes some of those details and appends them to another Google Sheet row. In normal circumstances this will happen relatively quickly and without clashes, but what if multiple people submit the Form at the same time!?

[Editor note: An alternative approach to tryLock() is waitLock(). The only different with a waitLock() is it will throw an exception after the set number of milliseconds. An example of waitLock() with onFormSubmit is included in the reference documentation]

Source: The Gift of Script: Control Form submissions with Script Lock

How you can use Google Forms, AI, and Apps Script automation to analyze 1,700 survey responses (and the 1,000th AppsScriptPulse post)

This post describes how I designed and ran an audience survey with over 1,700 responses, using Google Forms, Sheets, Apps Script, and ChatGPT. I’ll show you the entire process from end-to-end, including how I:

  • Created a survey with Google Forms
  • Used Apps Script to automatically say thank you to 1,700 respondents
  • Analyzed the response data in Google Sheets
  • Used AI to help me understand the qualitative data
  • Presented the results in Google Docs

It’s rather fitting that the 1,000th Pulse post features content by the one and only Ben Collins! Back in late 2019, when I was thinking about creating a new community site for Google Workspace developers, Ben’s encouragement was the spark that ignited AppsScriptPulse.

And today’s post by Ben is a nice example of Apps Script’s power to automate repetitive tasks. As part of this he shows how to craft personalised “thank you” emails for Google Form survey response with Google Apps Script. Ben’s insights go beyond ‘thank-you’s as he outlines how he administers and analyses customer surveys, highlighting his design choices for Google Forms and data analysis using built-in Google Sheets functions.

To take things a step further, Ben also highlights how he used ChatGPT to categorize qualitative survey responses. With Google’s recent announcement of their new AI model, Gemini, which outperforms ChatGPT  in a number of academic benchmarks, it would be interesting to see how these two platforms compare for this type of analysis.

Raising a glass (or an espresso :) to Ben and this 1,000-post milestone!

Source: How To Analyze Google Forms Survey Data with AI and Apps Script

Adding users to Google Chat spaces on demand with Google Apps Script

Image credit: Pablo Felip

A Chat space membership authorization workflow built using Google Forms, Sheets and Apps Script. … In the coming sections, we’ll build a workflow for process managers to review and authorize membership requests sent by users willing to join a predefined set of chat spaces.

Lots of talk about Meta’s new Threads … is there an API for that. Meanwhile Pablo Felip has been busy putting together this very comprehensive tutorial which explains how you can use Google Forms as part of a process to administer Google Chat Spaces membership.

The API call spaces.members.create is relatively straightforward when compared to the amount of effort to setup the Google Cloud project. This is all covered in the source post and the code provided can easily be modified to suit other worksflows.

Source: Adding users to Google Chat spaces on demand with Apps Script

Auto close Google Form after X responses with Google Apps Script

The following Google Apps Script is designed to automatically close a Google Form once it has reached the number of responses you specify.

Use Apps Script code to automatically close a Google Form

Use Apps Script code to automatically close a Google Form

Do you ever create a Google Form and then forget to close it? Or maybe you want to limit the number of responses that a form can receive? If so, you can automatically close a Google Form once it has reached the number of responses you specify with this example Google Apps Script.

Source: The Gift of Script: Auto close Google Form after X responses

The Ultimate Google Apps Script Front-End Development Guide. Part 0: The Worst and the Best Practices

Welcome to the Ultimate Google Ultimate Google Apps Script Front-End Development Guide!

If you are reading this post, then you likely have experience with Google Apps Script. Essentially, there are three types of front-ends that you can create with Apps Script:

  • Web apps
  • Modal/modeless dialogues
  • Sidebars

In this blog post series, we will only discuss HTML front-ends, as this is where you can create the most powerful and sophisticated user experiences. Unfortunately, the Card Service is outside the scope of this series, and it is not nearly as powerful as an HTML front-end. With that in mind, Google, how about allowing HTML front-ends for Workspace add-ons?

Source: The Ultimate Google Apps Script Front-End Development Guide. Part 0: The Worst and the Best Practices

Handling Google Forms checkbox responses with Google Apps Script

Get Google Form responses for checkbox-type questions and perform further actions depending on their values.

Get all checkbox responses from a Form

Get all checkbox responses from a Form

The following Google Apps Script is an example of one way to get the responses from a Checkbox-type question on a Google Form and how you might go about differentiating them.

This came up for a project I was working on where I need to put a Yes/No value into 3 separate Google Sheet cells based on 3 options in a question. The slight challenge is that all of the responses come out as a single array for this question, containing the strings of the values that have been ticked only.

Source: The Gift of Script: Google Form Checkbox responses

Setup automated reminders in Google Forms/Google Sheets with Apps Script

 

In this article I’ll show you how to setup reminder emails that will get sent automatically each day if there are any pending tasks in your spreadsheet. Stay tuned until the end, where I’ll show you an easier way to accomplish this using Coda.

Eric Koleda must be the undisputed master of the Apps Script demo. The ‘random cat’ Add-on, is one of my favourite examples where Eric finds a really simple hook to get you engaged in what can often be a complex project. Eric is now Developer Advocate at Coda and he’s not lost is eye. In this post Eric gives the gift of script with a basic example of how you can handle email notifications from Google Form responses in batches with a timed trigger (cats being replaced for cakes). Eric also shows how a no-code alternative can be accomplished in Coda.

Source: Setup automated reminders in Google Sheets

Opening and closing Google Forms on time trigger using Google Apps Script

This is a sample script for opening and closing Google Forms on time using Google Apps Script.

Here’s a handy little snippet if you would like to programmatically open/close one of your Google Forms to responses for specific hours of the day. The script includes another trigger that will repeat opening/closing the Google Form for responses each day. As this snippet uses .timeBased().at(date)  it’s easy for you to modify if you want to only have the form open to responses between two specific dates/times.

Source: Opening and Closing Google Forms on Time using Google Apps Script

Creating a custom workflows using Google Forms and Google Sheets for provisioning virtual machines (VM) in Google Cloud

Is it possible to integrate Google Workspace tools such as Calendar, Sheets, and Forms with Workflows? For example, can you trigger a workflow from a Google Form or a Sheet? Turns out, this is not only possible but also easier than you might think. Let me show you how with a sample use case.

One of the great things about Google Workspace is there is never ‘one’ solution, there is enough flexibility for you to implement one of many workflows. A case in point is this post highlighting a Google Forms/Sheets powered approval system for allocating virtual machines (VM) to your users. As part of this the workflow includes calling the Compute Engine API to create the VM in Google Cloud.

Source: Triggering Workflows from Google Sheets

GWAOw! 4 – Forms History a Google Forms Add-on by Martin Hawksey

Forms History is a Google Workspace Add-on that allows you to monitor your version history and store copies in Google Forms

Not just talking the talk, but also walking the walk. Shortly before taking a new role at CTS, the largest dedicated Google Cloud Partner in Europe, I published Forms History an add-on to enable revision history functionality in Google Forms.

Fellow Google Developers Expert, Scott Donald, has picked this up in the latest episode of GWAOw! his dedicated to Google Workspace Add-on review show. You can follow the source link for the YouTube clip and more. As part of the episode Scott rightly highlights the creative work of Alice Keeler, which hasn’t just included artwork but Alice has also provided a huge amount of support in promo and usability.

If you are interested in the inner workings of Forms History there is a related post on Working with the Google Drive API Revisions history: Tips for handling revision merges with Google Apps Script.

Source: GWAOw! 4 – Forms History by Martin Hawksey – Yagisanatode