What is the onFormSubmit trigger in Google Sheets?

The onFormSubmit trigger runs an Apps Script function when a linked Google Form adds a new row to your spreadsheet. It fires after the response lands in the sheet, so your script can route data, send notifications, or stamp IDs without waiting for someone to open the file.

When to use it

Use onFormSubmit when a form feeds a sheet and you need automatic follow-up: assign owners, email confirmations, copy rows to another tab, or validate answers the moment they arrive.

When to skip it

Skip onFormSubmit if Google Forms email notifications or simple formulas are enough. Do not use it for edits made directly in the grid; use onEdit or an installable edit trigger instead.

How it works

  1. 1

    Link a Google Form to a spreadsheet so responses create rows on a Responses tab.

  2. 2

    Open Extensions > Apps Script and write a handler function, for example processFormSubmit(e).

  3. 3

    Add an installable trigger from the Triggers page with event type On form submit.

  4. 4

    The event object e includes e.values (array of submitted answers) and e.range (the new row).

  5. 5

    Authorize the script the first time it needs MailApp, UrlFetchApp, or other restricted services.

  6. 6

    Keep the handler fast and log errors so missed rows are easy to find in Executions.

Examples in Google Sheets

Welcome email on signup

onFormSubmit reads the email column from e.values, builds a subject line, and calls MailApp.sendEmail with a thank-you message and next steps.

Route by department

If the answer in column C is Sales, append key fields to a Sales Leads tab and set status Pending in the response row.

Generate a ticket ID

Read the last used ID from a Settings tab, increment it, and write the new ticket number into column A of the submitted row.

Build this without starting from a blank cell

Use a Better Sheets tool for onFormSubmit trigger, then watch a walkthrough when you want the full pattern.

Better Sheets resources

Common mistakes

  • Expecting a simple function named onFormSubmit to run without creating an installable trigger in the Triggers UI.
  • Confusing form submit with onEdit when someone types directly into the Responses sheet.
  • Sending an email on every submit without checking for duplicate submissions or spam.
  • Assuming column order in e.values matches your visual headers after someone reorders form questions.
  • Running slow external API calls synchronously, causing the trigger to time out before the row is fully processed.

Frequently asked questions

Does onFormSubmit run for manual row edits?
No. It runs when a form submission adds a row. Direct edits in the sheet use onEdit or other triggers, not onFormSubmit.
What is in the event object e?
e.values is an array of submitted answers in form order. e.range points to the new row range. e.namedValues may also be available depending on form setup.
Do I need an installable trigger?
Yes. onFormSubmit is not a simple trigger like onOpen. Create it from Apps Script > Triggers > Add trigger.
Can onFormSubmit call MailApp?
Yes, after the script owner authorizes mail permissions. The email sends from the account that authorized the script.
Why did my trigger not fire?
Confirm the form is linked to this spreadsheet, the trigger points to the correct function, and there are no syntax errors in Executions.
Can one form trigger multiple functions?
You can attach multiple installable triggers to the same form submit event, but one well-structured handler is easier to debug.
Does the sheet need to be open?
No. Installable onFormSubmit runs in the cloud when the form is submitted, even if nobody has the sheet open.
How is this different from Google Forms email notifications?
Form notifications are fixed templates. onFormSubmit lets you branch logic, write to other tabs, call APIs, and customize messages from sheet data.

Related Tutorials

Watch how onFormSubmit trigger works

Browse more tutorials
Create New Worksheet When Google Form Submitted

Create New Worksheet When Google Form Submitted

Automate copying a template for new form submissions with user data inse...
Email Certain Department Based on Google Form Entries

Email Certain Department Based on Google Form Entries

Message a certain department when google form is submitted.
How to Create a Google Form Automatically

How to Create a Google Form Automatically

How to create a form programmatically using Google Apps Script. I show y...
Send Better Email When Google Form Filled Out

Send Better Email When Google Form Filled Out

Find out how to email all the form entries each time your form is filled...
Embed Email Form and Name Form into Website to Google Sheets

Embed Email Form and Name Form into Website to Google Sheets

Add names to the Email2Sheet apps script and code.
What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users

What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users

Learn about triggers, hourly, daily, weekly, etc.

Related blog posts

Guides that explain onFormSubmit trigger in more depth.

Browse the blog

Related glossary terms

Done reading about onFormSubmit trigger?

Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.

Need this once

Jump to a free tool or a single tutorial for this topic.

Learning Sheets for real

Unlock the full library, generators, and templates with membership.