Google Apps Script for Google Forms: A Beginner's Guide

Quick answer: Google Apps Script is Google's free, built-in JavaScript platform for automating Forms, Sheets, and other Workspace apps. It's how people add things Forms doesn't do natively — like emailing the owner on every submission, limiting responses automatically, or generating a PDF confirmation. It does require basic coding knowledge, which is its real barrier to entry.

Google Forms is deliberately simple, which means a lot of common requests — "email me when someone submits," "stop accepting responses after 50," "validate this field in a way Forms doesn't support" — aren't handled out of the box. Google Apps Script is the tool Google gives you to close that gap yourself, for free, without leaving the Google ecosystem. This guide explains what it is, what it can realistically do for your form, a simple example of how it's structured, and who it's actually for.

What is Google Apps Script?

Apps Script is Google's built-in scripting platform, based on JavaScript, that lets you write small programs that interact with Google Workspace apps — Forms, Sheets, Docs, Gmail, Calendar, and more. It runs entirely on Google's servers, so there's nothing to install and no separate hosting to manage. You access it in one of two places: from your form's three-dot menu, choose Apps Script (labelled Script editor in older versions of the interface), or open the linked Google Sheet and go to Extensions > Apps Script. Both routes open the same kind of editor, though scripts attached to the form versus the sheet have slightly different starting context.

What Apps Script lets you do that Forms doesn't offer natively

A simple example, explained conceptually

Here's the rough shape of a script that emails the form owner when someone submits. This is illustrative to show the structure — not something to copy-paste as production-ready code without adapting it to your form's actual questions.

function onFormSubmit(e) {
  // e.response holds the submitted form response
  var responses = e.response.getItemResponses();
  var summary = "";

  responses.forEach(function (itemResponse) {
    summary += itemResponse.getItem().getTitle() + ": " + itemResponse.getResponse() + "\n";
  });

  // Send the owner an email with the new response
  MailApp.sendEmail("[email protected]", "New form response", summary);
}

The key pieces: onFormSubmit(e) is a trigger function — Apps Script calls it automatically when a new response comes in, and e holds the event data, including e.response, which gives you access to each answer through getItemResponses(). From there, the script can do anything Apps Script's services support — send email, write to a sheet, call an outside API, generate a document. The trigger itself is configured separately in the editor's Triggers panel, where you tell it to run this function "On form submit."

Setting it up, step by step

  1. Open the Apps Script editor from your form's three-dot menu, or via Extensions > Apps Script on the linked Sheet.
  2. Write a trigger function like the example above, reading the submitted answers from the event object.
  3. Add your automation logic — the actual email, PDF, or check you want to run.
  4. Set up the trigger in the Triggers section (the clock icon in the left sidebar), adding a new trigger that runs your function on the "From form" / "On form submit" event.
  5. Authorize and test. The first run will prompt you to grant the script permission to access your form and Gmail; approve it, then submit a real test response to confirm everything fires correctly.

Where to learn more

Apps Script has extensive official documentation directly from Google, covering the Forms service, triggers, and every other Workspace app it can touch. If you're serious about writing your own scripts, that's the most reliable and up-to-date reference, since it's maintained alongside the product itself rather than by a third party.

Common triggers beyond "on form submit"

Form submission is the most common trigger, but not the only one useful for forms. A time-driven trigger (also set up in the Triggers panel) can run on a schedule — hourly, daily, or at a specific time — independent of whether anyone submitted a response. This is what powers scheduled actions like automatically closing a form at a set date, sending a daily digest of the day's responses instead of one email per submission, or archiving old responses into a separate sheet on a rolling basis. Editor-based triggers (onEdit) fire when someone changes a cell in the linked spreadsheet, which is useful if you want a script to react when you manually mark a response as "processed" or "approved" in a status column.

Troubleshooting Apps Script issues

  1. Script doesn't run when a form is submitted: confirm the trigger is actually saved and pointed at "On form submit," not a different event type — triggers created in earlier test sessions can silently exist alongside a newer, misconfigured one, so check the Triggers panel for duplicates.
  2. "Authorization required" errors on every run: Apps Script permissions can be revoked if you change your Google account password or if Google periodically re-checks sensitive scopes like Gmail sending. Re-run the script manually from the editor once to re-trigger the authorization prompt.
  3. Script works when run manually but not automatically: some Apps Script services (like showing a UI dialog) only work when a human runs the script directly, not from an automated trigger — automated triggers must use non-interactive actions like sending email or writing to a sheet.
  4. Emails aren't sending: Apps Script's free tier has a daily email quota (higher on a Google Workspace account than a personal Gmail account) — high-volume forms can hit that ceiling, causing later emails in the day to silently fail.

The honest barrier to entry

Apps Script requires actual coding — specifically, basic JavaScript. It is not a no-code tool, and treating it like a simple settings toggle will lead to frustration if you've never written code before. Reading and adapting a short example like the one above is realistic for a motivated beginner, but building something more involved, like multi-step validation or PDF generation, takes real programming knowledge.

That barrier is exactly the gap that no-code third-party add-ons fill for people who need automation without writing scripts, and it's the same gap that purpose-built apps like FormMaker fill for a different problem entirely — making and managing the form itself on mobile, without needing to touch code at all. Neither replaces Apps Script for deep customization, but neither requires it either.

Form-bound vs sheet-bound scripts: what changes

Where you create the script decides what the submit event gives you. Mixing the two is the most common reason a copied example fails.

Script created from the formScript created from the linked Sheet
Open it fromForm editor → ⋮ → Apps ScriptSheet → Extensions → Apps Script
Main serviceFormAppSpreadsheetApp
Submit event containse.response (a FormResponse object)e.values (array of cell values) and e.namedValues (answers keyed by column header)
Best forChanging the form itself: closing it, updating choices, reading responses before they reach a sheetWorking with the row: formatting, lookups, writing status columns, building reports

If an example uses e.namedValues, it belongs in a sheet-bound script; if it uses e.response.getItemResponses(), it belongs in a form-bound one. A sheet-bound script also needs the form to be linked to that sheet first (Responses → Link to Sheets) — see linking Google Forms to Google Sheets.

Three more practical examples

These are short, illustrative sketches to show what's possible. Test them on a copy of your form first; question titles, sheet names and limits are placeholders you need to change.

1. Close the form automatically after a set number of responses

function closeWhenFull() {
  var form = FormApp.getActiveForm();
  var limit = 50; // illustrative cap
  if (form.getResponses().length >= limit) {
    form.setAcceptingResponses(false);
    form.setCustomClosedFormMessage("Sorry, this form is full.");
  }
}

Attach this function to a form-bound "On form submit" trigger. Each submission re-checks the count; when it reaches the limit, the form stops accepting responses and shows your custom message. Note that two people submitting at almost the same moment can both get in, so the final total may land slightly above the cap.

2. Email respondents a copy with a custom message

function sendConfirmation(e) {
  var email = e.response.getRespondentEmail();
  if (!email) return; // requires email collection to be turned on
  var body = "Thanks for registering. Here is what you submitted:\n\n";
  e.response.getItemResponses().forEach(function (r) {
    body += r.getItem().getTitle() + ": " + r.getResponse() + "\n";
  });
  MailApp.sendEmail(email, "Your registration", body);
}

getRespondentEmail() only returns an address when the form collects emails (Settings → Responses → Collect email addresses). If you only need a plain receipt, the built-in "send responders a copy" option may be enough — see sending respondents a copy of their response.

3. Refresh dropdown choices from a sheet

function refreshChoices() {
  var form = FormApp.openById("YOUR_FORM_ID");
  var names = SpreadsheetApp.openById("YOUR_SHEET_ID")
    .getSheetByName("Options").getRange("A2:A").getValues()
    .flat().filter(String);
  var item = form.getItems(FormApp.ItemType.LIST)[0].asListItem();
  item.setChoiceValues(names);
}

Run it on a time-driven trigger (for example, every morning) to keep a list of session times, products or staff names current without editing the form by hand. Removing a choice that has already been picked can make "remaining spots" style logic tricky, so pair this with a status column if you track availability.

Creating a whole form with code

Apps Script can also build forms from scratch with FormApp.create("Title"), then add items such as addMultipleChoiceItem(), addTextItem() and addPageBreakItem(). Teams use this to generate many near-identical forms — one per class section, store or event — from a spreadsheet of settings. It's powerful but slow to write and maintain. If you just need one well-structured form quickly, describing it in plain English to an AI form generator or starting from a template is usually faster, and you can still attach scripts to the resulting Google Form afterward because it's a normal form in your account.

Debugging: where to look when nothing happens

  1. Executions. In the Apps Script editor's left sidebar, the Executions page lists every run, whether it was started manually or by a trigger, and whether it failed. Click a failed run to see the error message and line number.
  2. Logs. Add console.log(JSON.stringify(e)) at the top of your function, submit a test response and read the log in Executions. This shows exactly what the event object contains.
  3. Don't press Run on a submit function. Running onFormSubmit(e) from the editor's Run button gives it no event, so e is undefined and the script errors. Test by submitting the live form instead.
  4. Failure notifications. Each trigger has a failure-notification setting (immediately, daily or weekly). Set it to immediately while you're testing.
  5. Question titles changed. Scripts that look answers up by title break silently when someone edits the question text. Prefer item IDs or keep a note in the form description that titles are used by a script.

Security, permissions and ownership

When a script first runs, Google shows a consent screen listing what it can access, such as "send email as you" or "see, edit, create and delete your spreadsheets". Read it. A script you paste from the internet runs with your permissions, so never authorize code you don't understand, and be cautious with scripts that call outside URLs with UrlFetchApp and form data, since that sends respondents' answers to a third party.

Installable triggers belong to the person who created them. Emails are sent from that person's account and count against their quota, and if that person loses access or leaves the organization, the trigger can stop. For school and business forms, create triggers from a shared role account or an account that won't be deprovisioned, and document what each script does. Google's own quota and limits pages list the current daily caps; check them instead of relying on numbers quoted in blog posts, since they change.

If the form collects personal data, remember that anything your script copies (into emails, other sheets or outside services) is another place that data now lives. This is general information, not legal advice; your school or company may have rules about where student or employee data can go.

Apps Script vs add-ons vs Zapier: which to use

OptionCoding neededGood forWatch out for
Built-in Forms settingsNoneOwner alerts, response limits per person, closing manually, respondent copiesLimited customization
Apps ScriptBasic JavaScriptCustom emails, automatic closing, dynamic choices, documents and PDFsMaintenance, quotas, trigger ownership
Marketplace add-onsNoneCommon jobs like limiting responses or emailing notificationsPermissions granted to a third party; free tiers may be limited
Zapier / MakeNoneSending responses to non-Google tools (CRMs, Slack, email platforms)Paid plans for volume; delays on some plans

Browse vetted options in our Google Forms add-ons guide, or compare the no-code route in Google Forms + Zapier. Developers who want to work with forms from outside Google's servers should look at the Google Forms API instead.

FAQ

What is Google Apps Script?

Google Apps Script is Google's built-in JavaScript-based platform for automating and extending Google Workspace apps, including Forms, Sheets, and Gmail. It runs on Google's servers for free and requires no separate installation.

Can Google Forms send an automatic email when someone submits?

Partly. Google Forms can notify the account that enables it (Responses, then the three-dot menu, then Get email notifications for new responses), but the message doesn't include the answers and can't go to other addresses. Apps Script can send a custom email with the full response to anyone, every time a submission comes in.

Do I need to know how to code to use Apps Script?

Yes, at least basic JavaScript. Apps Script is a real coding environment, not a no-code tool. If you don't want to write code, look at no-code add-ons or purpose-built apps instead.

Where do I open the Apps Script editor for a Google Form?

From your form, go to the three-dot menu and choose Apps Script (Script editor in older interfaces), or open the linked Google Sheet and go to Extensions > Apps Script.

Is there a limit to how many emails Apps Script can send per day?

Yes. Apps Script enforces a daily email-sending quota that's higher for Google Workspace accounts than for free personal Gmail accounts. High-volume forms that email on every submission can hit that ceiling, which is worth checking if emails stop sending partway through a busy day.

Why does my script say e is undefined?

You probably ran the submit function with the editor's Run button. Trigger functions only receive the event object when a real trigger fires, so test by submitting the live form and reading the result on the Executions page.

Will my script keep working if I make a copy of the form?

A form-bound script is copied along with the form, but installable triggers are not. Open the copy's Apps Script editor and recreate the trigger in the Triggers panel, then authorize it again.

Can I use Apps Script with forms created by FormMaker?

Yes. FormMaker creates normal Google Forms in your own Google account, so you can open any of them in the Google Forms editor and add a script exactly as you would for a form you built by hand.

Related guides