user3934101
user3934101

Reputation: 3

HTML file in UiApp Google Apps Script

I am working on a small Google Apps Script and right now I am stuck because I made a Google Picker in an HTML file but I can't access it in my UiApp Application.

I tried this...

var eButton = app.createHTML(HtmlService.createTemplateFromFile('GooglePicker.html').evaluate());

...but it's not working. Is there a way to build up an HTML within a UiApp?

function doGet() {
  var app = UiApp.createApplication().setTitle('BlueTurbo');

  var eButton = app.createHTML(HtmlService.createTemplateFromFile('GooglePicker.html').evaluate());

  // Create a grid with 3 text boxes and corresponding labels
  var grid = app.createGrid(3, 3);

  // Text entered in the text box is passed in to ID
  grid.setWidget(0, 0, app.createLabel('Folder ID : '));
  grid.setWidget(0, 1, app.createTextBox().setName('ID'));
  grid.setWidget(0, 2, eButton);

  // Text entered in the text box is passed in to name.
  grid.setWidget(2, 0, app.createLabel('Nom : '));
  grid.setWidget(2, 1, app.createTextBox().setName('name'));

  // Text entered in the text box is passed in to emails
  grid.setWidget(1, 0, app.createLabel('Emails : '));
  grid.setWidget(1, 1, app.createTextBox().setName('emails'));

  [...] //More code

  return app;
}

Upvotes: 0

Views: 302

Answers (1)

Serge insas
Serge insas

Reputation: 46794

You can't mix UiApp and HTML Service in the same script.

You can use the drive showDocsPicker() described here instead.

In the doc we can read this :

Using UiApp's HTML widget it's possible to add custom HTML markup to your application. There are restrictions on the type of content that can be added to this widget however, and only the following set of HTML tags can be used: b, blockquote, body, br, center, caption, cite, code, div, em, h1, h2, h3, h4, h5, h6, hr, i, label, legend, li, ol, p, span, strong, sub, sup, table, tbody, td, thead, title, tr, tt, ul To take advantage of the full set of HTML features, consider using the HTML service to build your user interface instead of UiApp.

Upvotes: 2

Related Questions