Frage

I have a small form that my colleagues and I often fill out that can be seen here, with source code (view-only) here. The spreadsheet that this form posts to can be seen (view-only) here.

Basically, the apps script is solely for preventing my coworkers from having to scroll through thousands of rows of a spreadsheet (this is also used for our film collection) to check in/out inventory. It will also, soon, post detailed history of the checkout in an audit spreadsheet.

I have attempted, with no success, to clear the values of the text fields after the data has been posted to the spreadsheet. What I essentially want to do is restart the GUI so that the fields are once again blank.

I have tried accessing the text fields by id but the return type is a Generic widget, which I of course can't do anything with. And since control is passed to the handler functions, the text fields can't be accessed, or at least I can't figure out how (and I looked through the documentation and online solutions for hours last night).

So the question: how can I erase/clear the values of the text fields in the GUI after values have been posted to the spreadsheet? (return from handler function to access text fields again, or restart the GUI?

I can accomplish restarting the script runs on a spreadsheet, but I have not been able to do this when it is embedded in a Google site.

War es hilfreich?

Lösung

The getElementById('xxxxx').setText('') approach was the right way to do it. but the way you tried to test it doesn't work... the new value would only be available in the next handler call.

 /*
    This function only has the desired effect if it is called within the handler
    function (not within a nested function in the handler function).
 */
 function restartGUI() {

  var gui = UiApp.getActiveApplication();

  gui.getElementById('equipmentIDField1').setText('');
  gui.getElementById('equipmentIDField2').setText('');
  gui.getElementById('equipmentIDField3').setText('');
  gui.getElementById('studentLastNameField').setText('');
  gui.getElementById('labasstLastNameField').setText('');
  return gui;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top