lonewolf
lonewolf

Reputation: 23

I get an error that getUi() is only available in the new version of google spreadsheets, but I'm using it on an newly created spreadsheet

I create a spreadsheet with following command:

var spreadsheet = SpreadsheetApp.create(name);

Then I add some data to it, then I make a trigger that goes off when you edit the spreadsheet. The handler function contains following code:

var rangePrice = sheet.getRange(4,15,17,1);

var values = rangePrice.getValues();
for( z = 0; z < values.length; z++){
 if(!(values[z] * 1 > 0)){
  Logger.log(rangePrice.getBackground());
  var ui = SpreadsheetApp.getUi();
  var result = ui.alert('message');
  return false;
 }
}

When I run the handler function, I get the following error:

De API-methode 'getUi' is alleen beschikbaar in de nieuwe versie van Google Spreadsheets.

In English: The API-method 'getUi' is only available in the new version of Google spreadsheets.

I ran this script last week and I didn't get the error, so it's really funny that I get it know. I'm also using a newly created spreadsheet so I don't see why I get that error. Any help?

Upvotes: 0

Views: 168

Answers (1)

dasjanik
dasjanik

Reputation: 326

As you are only using the UI Class to display a message better use the Browser Class (documentation - https://developers.google.com/apps-script/reference/base/browser) - it continues to work for every version of Spreadsheets (read: https://developers.google.com/apps-script/migration/sheets).

It's method msgBox(message) does the exact same thing as UI's method alert(message).

Also note

that SpreadsheetApp.getUi() should only ever be used in a script bound to a spreadsheet.

as mentioned here by a Google Developer.

Upvotes: 0

Related Questions