Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

google apps script - How to get onFormSubmit to trigger automatically?

The "fix" (test_onformsubmit) code you gave, I have to manually run it every time there is new data in the spreadsheet. I was wanting it to automatically send the pdf to email when Form is submitted. Is there a way? Because the manual way runs the code exactly like its supposed to, but I want this as an automatic event so I don't have to do anything.

See parent thread of original problem/question

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Read Understanding Triggers. This function is an Installable Trigger, so you need to set it up to run when a form is submitted. It's easy - I would have thought a Forms tutorial would have walked through it.

In the Script Editor:

  1. Choose Edit > Current project's triggers. You see a panel with the message No triggers set up. Click here to add one now.
  2. Click the link.
  3. Under Run, select the function you want executed by the trigger. (That's onFormSubmit(), in this case.)
  4. Under Events, select From Spreadsheet.
  5. From the next drop-down list, select On form submit.
  6. Click Save.

From this point on, the function will be triggered whenever a form is submitted to the spreadsheet.

If you plan to share your script, each recipient will need to repeat these steps.


As an aside, you should change the email setting in your script, so it will work for ANYONE.

var email_address = Session.getActiveUser().getEmail();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...