2

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;
}
1
  • This function just builds a UI object... How are you trying to display that UI? You can either publish a web app or as a dialog or sidebar from a script bound to a doc or sheet. Commented Dec 11, 2014 at 18:43

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.