In Google Scripts I'm trying to use a on form submit trigger, but all I see in events are Time-Driven and From Calendar
The project must be bound to the Google form or to the connected spreadsheet for the onFormSubmit trigger to be available in the triggers UI.
Open your Google form
Click Tools > Script editor from within the form
Related
I am trying to create a custom alert message in a Google Form, the idea is that once the user submits the form it should show a message displaying a result based on what the user inputs on the form.
I've tried to use Browser.msgBox() and getUi().alert() but they seem to only work in spreadsheets.
Is there any way to achieve this inside a form?
Answer:
This can not be done in Google Forms.
More Information:
According to Google's documentation on Simple and Installable triggers:
The open event for Google Forms does not occur when a user opens a form to respond, but rather when an editor opens the form to modify it.
If attempting to run the FormApp.getUi() method on an installable trigger on Form Submit, the following error appears in the Stackdriver logs under My Executions:
Error: Cannot call FormApp.getUi() from this context. at onSumbit(Code:2)
So unfortunately, this can not be completed.
References:
Google Apps Script - Simple Triggers
Google Apps Script - Class Ui
How to set a trigger when a close button is pressed on the spreadsheet.
is it actually possible?
The script I am using is google apps script
It is not possible. See here a list of triggers available on Google Scripts.
I am using a code which closes the FORM at specified time. So what happened is some students are failing to submit it before the time limit and their responses are not being recorded.
Is there any way to force auto-submit a google form at specified end-time for all the users who are writing the quiz lets say!
Any ideas are welcome.
You can check this documentation about Installable Triggers which let Apps Script run a function automatically when a certain event occurs. It is similar to simple triggers for Google Apps like onOpen(), but they can respond to additional events, and they behave differently.
There are several installable triggers for Google Apps and you can use an installable form-submit trigger that runs when a user responds to a form.
Be noted that there are two versions of the form-submit trigger, one for Google Forms itself and one for Sheets if the form submits to a spreadsheet.
The built-in onOpen trigger in Google Apps Script only runs when a user with permission to edit opens a spreadsheet or document. I am developing a spreadsheet where only developers have edit privileges and all other users must have view-only privileges.
How do I create an onOpen trigger that fires when view-only users open my spreadsheet as well as those with edit privileges?
You can't, because it's not supported. Google Apps Script, embedded in either Google Sheets, Docs, Forms, and as an add-on, runs only for editors.
The alternative is to Publish as a webapp, so the viewers open that instead of the sheet directly, or open the webapp (on another tab, not inside the sheet) from a link in a sheet cell.
From the "Restrictions" section of trigger documentation on triggers - both simple and installable:
They do not run if a file is opened in read-only (view or comment) mode.**
It seems that OnEdit only works for spreadsheet?
I have a google form to capture data and sends to user's Calendar. But is there a way to append data if user decides to edit the form submission?
I can't find a trigger for 'edit' of form submission.
Have a look at the google apps script guides.
https://developers.google.com/apps-script/guides/triggers/#available_types_of_triggers
There you see that the onEdit trigger is only available for Sheets. However, it seems you could use a installable trigger that will fire on form submit.