-1

I used Google Forms to create a questionnaire, and I created a formula for Google Forms answers using Google Scripts.

After that, I want to re-record the calculated result on the Google Sheet every time the questionnaire is done.

How can I trigger such a recalculation?

  • post a script you used and share a link to copy of your sheet – user0 Feb 14 '19 at 0:39
  • Many formulas are recalculated every time that a cell value changes. What is the formula that you want to be recalculated on each form submission? – Rubén Jul 14 '19 at 18:10
0

This will work if your script actively updates your spreadsheet. It will not work if you use your script as a formula (e.g. by putting =myScript() in a cell).

An example script that will work, by updating a cell in your spreadsheet with the current date:

function runThisOnFormSubmission() {
  SpreadsheetApp.getActive().getRange("B1").setValue(new Date());
}

To set up a trigger for the script, so that it will actually run on form submission:

  1. In the script editor, go to Edit → Current project's triggers.
  2. Click the Add Trigger button (lower right corner of the screen)
  3. A form pops up. Select:
    • Choose which function to run: (your function)
    • Choose which deployment to run: Head
    • Select event source: From spreadsheet
    • Select event type: On form submit
  4. You will be asked to grant permission to your script
  5. From now on, your script will be run when the form is submitted

To demonstrate this, I have set up an example spreadsheet and connected form. Feel free to copy them and experiment with them.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.