google apps script - GAS: Error encountered: An unexpected error occurred -


I have very little knowledge in coding with UI on Google Apps Script I try to apply a simple form to the spreadsheet I am doing Spreadsheets do two things:

  1. If a field is left empty, then it should create a warning message.
  2. After filling all the fields, the information should be input into the spreadsheet (not displayed in the code given below).

My stage 1 is failing badly because it gives me a popup error:

: An unexpected error occurred:

My code is more complex than the one given below but this also results in:

  Function A (e) {var doc = SpreadsheetApp.getActiveSpreadsheet (); Var app = UiApp.createApplication (). SetTitle ('new name'); Var form = app.createVerticalPanel () SetId ('form'); Var grid = app.createGrid (2, 3) .setId ('grid'); Grid.setWidget (0, 0, app.createLabel ('name:')); Grid.setWidget (0, 1, app.createTextBox (). SetName ('name')); Grid.setWidget (0, 2, app.createHTML (.) SetId ('nameRequired')); Grid .Set Widget (1, 0, App.Sent Button ('Submit') .addClickHandler (App.SecurityClickYellower ('B') .addClallElement (Grid)); Form.add (grid); App.add (form); Doc.show (app); } Function B (e) {var app = UiApp.getActiveApplication (); If (e.parameter.name == '') app.getElementById ('nameRequired') .setHTML ('& lt; font color = \' red \ '& gt; * required & lt; / font & gt;') ; . SpreadsheetApp.getActiveSpreadsheet () Show (app); }  

Any help would be greatly appreciated. Thanks!

Change the last line in back app in the headler function;

When you reuse, the spreadsheet app.Active Spreadsheet (). Show (app); In the Handler function, you are actually trying to add an example to UIEpe (which you called getActiveApplication () ) in the spreadsheet and it is generating an error.

Update

Code given below:

  function B (e) {var app = UiApp.getActiveApplication (); Logger.log (e.parameter.name); If (e.parameter.name == '') app.getElementById ('nameRequired') .setHTML ('* required'). SetStyleAttributes ({'color': 'red', 'fontWeight': 'bold'}); // Many combinations of used combinations of the object returns app, // update Ui}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -