-2

I'm trying to create a function that's trigerred when its container-bound Form is submited, then retrieves some cells from a spreadsheet and display them to the Form's user in an alert window.

Here's the code :

function displayResult() {
var sheet = SpreadsheetApp.openById("mySheetID");
var lastrow = sheet.getLastRow();
var range = sheet.getRange("BI" + lastrow + ":BM" + lastrow);
var values = range.getValues();
var form = FormApp.getActiveForm();
var ui = form.getUi();
ui.alert('values[0][0]');
}

Nothing happens on Form submission and I'm getting the following error message :

TypeError: Function getUi not found in object Form. at displayResult(Code:7)

Lucas P.
  • 125
  • 3
  • 12
  • There is no `getUi()` method of the Form class. You can use `var ui = FormApp.getUi()` See documentation: [Link - getUi](https://developers.google.com/apps-script/reference/forms/form-app#getui) – Alan Wells Dec 22 '17 at 17:46
  • When you open up a spreadsheet with a script there is no user interface because the spreadsheet has opened up on the server and there is no user. – Cooper Dec 22 '17 at 19:21
  • @SandyGood , I tried with `var ui = FormApp.getUi()` but it's not working. It gives me the following error : "Cannot call FormApp.getUi() from this context." @Cooper I don't want to open and modify Spreadsheet's UI, I want to do this on the current opened/submitted Form – Lucas P. Dec 26 '17 at 12:32
  • Custom dialogs do not work on a Google Form except when the Form is in Edit mode. – Alan Wells Dec 26 '17 at 13:11
  • Yeah indeed, saw that in the doc link you pasted here. Thanks for your help, I guess my problem is unsolvable then... – Lucas P. Dec 26 '17 at 14:58

1 Answers1

0

Unsolvable problem : As Sandy Good said, custom dialogs do not work on a Google Form except when the Form is in Edit mode.

Lucas P.
  • 125
  • 3
  • 12