scripter_T
scripter_T

Reputation: 21

Google Script UI dialog window doesn't open

This is just a simple script, since I'm new at coding in Google Script. I used their code to test a dialog, but the dialog window doesn't even open. Obviously I'm missing a piece of code, but am at a loss as to what. Here's my code. Thanks in advance!

function demoUI() {
  var myapp = UiApp.createApplication().setTitle('An improved GUI');

  var mygrid = myapp.createGrid(3, 2);
  mygrid.setWidget(0, 0, myapp.createLabel('Name:'));
  mygrid.setWidget(0, 1, myapp.createTextBox());
  mygrid.setWidget(1, 0, myapp.createLabel('Age:'));
  mygrid.setWidget(1, 1, myapp.createTextBox());
  mygrid.setWidget(2, 0, myapp.createLabel('City'));
  mygrid.setWidget(2, 1, myapp.createTextBox());

  var mybutton = myapp.createButton('Press me');
  var mypanel = myapp.createVerticalPanel();
  mypanel.add(mygrid);
  mypanel.add(mybutton);
  myapp.add(mypanel);
  return myapp;
}

Upvotes: 2

Views: 64

Answers (1)

Tovly Deutsch
Tovly Deutsch

Reputation: 663

You should replace return myapp; with

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
spreadsheet.show(myapp);

This example is for Google Sheets. You would need to change the code based on what app you are using.

However, the UiApp, which you are using, is deprecated. Use the HTML service to create Google Apps Script User Interfaces instead.

Upvotes: 1

Related Questions