This code works just fine if I run it when Form Editor is opened:
var ui = FormApp.getUi();
var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO);
// Process the user's response.
if (response.getSelectedButton() == ui.Button.YES) {
Logger.log('The user\'s name is %s.', response.getResponseText());
} else if (response.getSelectedButton() == ui.Button.NO) {
Logger.log('The user didn\'t want to provide a name.');
} else {
Logger.log('The user clicked the close button in the dialog\'s title bar.');
}
But it does not work on the Form View, when someone filling it, I dont understand why google made it work this way, what is the benefit of me seeing the dialog box and not the one filling it... Also, is it possible that I can get the response before the form is being submited so I can validate certain field by using some javascript function?
Alternatively how can I achieve such things on Google Forms apps script?
Google Apps Script only runs on the Google Form editor, not on the Form View.
Similar answers by other members to similar questions: