0

I have a Google Forms Quiz linked to a Google Sheet and an Apps Script 'From spreadsheet - On form submit' trigger linked to an Apps Script. Intermittently, this trigger fires twice causing a problem for my application.

I thought multiple versions of my AppScript may have inadvertently been deployed in parallel. But I have made sure to delete all other versions and 'Deploy as web app...' using a new version number with 'Only myself' having access to the app.

I have also tried using a lock in the script to limit execution to one at a time and have tested whether double-clicking the 'Submit' button on the Google Forms Quiz will cause this behaviour.

I would expect the trigger to fire once per Google Forms Quiz submit button press.

Ben Druitt
  • 51
  • 1
  • 2
  • 2
    Possible duplicate of [How can I be getting multiple unwanted event blocks from the same onFormSubmit Trigger?](https://stackoverflow.com/questions/54834837/how-can-i-be-getting-multiple-unwanted-event-blocks-from-the-same-onformsubmit-t) – Joshua T Jun 04 '19 at 06:08
  • For my example, each trigger iterates through the rows in my Sheet to find quiz submissions which are 100% correct and then assigns a GUID to each row which does not have one. It appears that when onFormSubmit trigger fires the GUID is generated for the new row twice with the second firing being the GUID that remains saved in the sheet. I will setup a simple example for myself to understand whether integrating e.values (as suggested in duplicate) can help me 'logic' my way out of this problem and report back here as to whether I have a problem which differs from the suggested duplicate. – Ben Druitt Jun 04 '19 at 06:43
  • I feel your issue is similar to mine here: https://stackoverflow.com/questions/62275601/onformsubmit-trigger-occurs-twice-randomly-about-every-few-weeks – Mahmoud Maarouf Jun 09 '20 at 05:27

1 Answers1

0

In the end the solution to this problem was to handle the spurious double OnSubmit events by calling SpreadsheetApp.flush(); to ensure that my spreadsheet changes were committed before processing any second firing of the OnSubmit event. In this way my application was able to handle the issue.

Ben Druitt
  • 51
  • 1
  • 2