3

This scenario is within my company, with google accounts.

I have a google form which of course populates a spreadsheet. My google apps script basically creates a pdf document from the form content and sends it by email to an HR email address. The script also inserts a link to the created pdf in the line on the spreadsheet that has just been populated by the last form submit.

Everything works fine, except the script is triggered automatically a second time after a while creating a second empty pdf, because the form hasn't really been submitted again. It might happen immediately, or after a few minutes, even it once happened one hour after the first execution.

This is owned by a service account. Inside the same account I have another form/spreadsheet/script/trigger which does almost the same and it works just fine, being triggered only once.

The only difference is that the form that works fine, collects the email addresses automatically, so requires a user to login to google. The faulty one, does not collect the email addresses, it just has the fields "full name" and "username" instead for the person to identify manually.

The executions of both triggers of course, end as "completed".

I been erasing and recreating triggers for two days. Even created the faulty form from scratch, because originally I had duplicated the good one and then modified it accordingly.

You can see in the image, the execution at 6:04:49 is a "ghost" of the one one second before. (of course I cannot do all the form filling process in just 1 second) Then another real execution at 5:33:42 and its ghost 4 seconds after that. Then the 3 executions at 5:39:07 seem to be ghots of previous ones done at different times.

Any clues?? Thanks a lot!

tehhowch
  • 9,645
  • 4
  • 24
  • 42
  • 1
    Did you search at all before posting? This is a common question in the last 2 weeks. https://stackoverflow.com/questions/55283616/script-running-multiple-times-onformsubmit https://stackoverflow.com/questions/54834837/how-can-i-be-getting-multiple-unwanted-event-blocks-from-the-same-onformsubmit-t https://stackoverflow.com/questions/55188211/google-app-script-triggering-twice-after-google-form-submit https://stackoverflow.com/questions/55094771/onformsubmit-running-multiple-times https://issuetracker.google.com/issues/124283798 https://issuetracker.google.com/issues/128591842 – tehhowch Mar 29 '19 at 17:47
  • 1
    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) – tehhowch Mar 29 '19 at 17:48
  • I did, but apparently did it very poorly, hehe! Thanks for the links! – Federico Joly Mar 29 '19 at 19:38
  • I'm still not sure where to put the lock in my code. I put it in the bit that handles the spreadsheet, but the result is that the link doesn't get created on the spreadsheet. The rest of the behaviour is the same. It's very annoying cause I got the "ghost" triggers 20, 30 or even over 60 minutes after the first execution. – Federico Joly Mar 30 '19 at 12:04
  • How should I implement this? if(e.values && !e.values[1]){return;} where e.values[1] Thanks again! – Federico Joly Mar 30 '19 at 12:40

0 Answers0