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:
- Choose Edit > Current project's triggers. You see a panel with the message No triggers set up. Click here to add one now.
- Click the link.
- Under Run, select the function you want executed by the trigger. (That's
onFormSubmit()
, in this case.)
- Under Events, select From Spreadsheet.
- From the next drop-down list, select On form submit.
- 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();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…