---
title: "Avoiding Google Apps Script onFormSubmit simultaneous executions when unlinking/linking Google Sheet responses"
author: "Phil Bainbridge"
date: 2024-04-15T19:57:35+00:00
canonical_url: https://pulse.appsscript.info/p/2024/04/avoiding-google-apps-script-onformsubmit-simultaneous-executions-when-unlinking-linking-google-sheet-responses/
markdown_url: https://pulse.appsscript.info/p/2024/04/avoiding-google-apps-script-onformsubmit-simultaneous-executions-when-unlinking-linking-google-sheet-responses.md
categories:
  - "Forms"
  - "Gotchas"
  - "Sheets"
tags:
  - "pbainbridge.co.uk"
featured_image: https://pulse.appsscript.info/files/2024/04/onSubmitForm.jpg
description: "Phil Bainbridge shares a heads-up for anyone using Google Forms with custom scripts. It turns out that unlinking and then relinking the response sheet can trigger your script hundreds of times at once! You can read more about how this happens and ways to workaround."
---

# Avoiding Google Apps Script onFormSubmit simultaneous executions when unlinking/linking Google Sheet responses

![Avoiding Google Apps Script onFormSubmit simultaneous executions when unlinking/linking Google Sheet responses](https://pulse.appsscript.info/files/2024/04/onSubmitForm.jpg)

> Caution when using onFormSubmit triggers to avoid mass simultaneous executions when un/linking a Response Sheet.

The following post is a caution around [onFormSubmit triggers**](https://developers.google.com/apps-script/guides/triggers/events#Google%20Forms-events) after I recently discovered a way that somebody had inadvertently managed to execute my code simultaneously over 253 times. Now unless a Google Form is submitted by 253 individuals all at the same time … then this is baffling.

**When should an onFormSubmit trigger run?**

At the point when a Google Form has been completed and the ‘Submit’ button pressed.

**How else can the trigger be activated?**

Well … it turns out when you unlink and then link back a Google Response Sheet containing the onFormSubmit trigger, it will activate it for every single Form response collected up to that point in time …

Source: *[The Gift of Script: onFormSubmit Trigger simultaneous executions*](https://www.pbainbridge.co.uk/2024/04/onformsubmit-trigger-simultaneous.html)

---

*Published by [Phil Bainbridge](https://pulse.appsscript.info/p/author/phillipbainbridge/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2024/04/avoiding-google-apps-script-onformsubmit-simultaneous-executions-when-unlinking-linking-google-sheet-responses/](https://pulse.appsscript.info/p/2024/04/avoiding-google-apps-script-onformsubmit-simultaneous-executions-when-unlinking-linking-google-sheet-responses/)*
