Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 959
user2640294 Avatar asked Aug 01 '13 11:08

user2640294


People also ask

Can you set a macro to run automatically in Google Sheets?

You can set your macro to run based on actions, calendar updates, time intervals, or a chosen time and date. On your computer, open a spreadsheet at sheets.google.com. Script editor. Current project's triggers.

How do I add a trigger to a Google form?

Place the pointer on the start action, and then click or double-click the action. A list of triggers appear. 2. Select the Google Forms trigger and then and then create a new event.


1 Answers

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();
like image 90
Mogsdad Avatar answered Sep 21 '22 11:09

Mogsdad