0
votes

Has anyone ever come across this error before from running UI App published as web app?:

Error encountered: Cannot find method (class)getRange((class),number,number,number).

I googled the phrase and came up with zero search results.

The web app loads fine from the doGet(), and the error comes up after a small server handler operates. Thing is the handler runs through everything fine (My "processing..." label at the end of handler function switches visibility off) and the spreadsheet I'm calling is updated no problem. I checked my code, and all my getRanges are properly formatted with sheet.getRange(row,col,num,num).

GAS acted weird once yesterday with an odd error it seems when they updated the Ctrl-F find ability yesterday, but that was fixed with a simple refresh of that page. I have refreshed after today's new error but it still comes up after running the handler. Anyone else running into this or have a solution?


Well, I've copy pasted the code into another script, and made a copy of the spreadsheet I am calling, but I still get the error. Here is the "offending" code according to google's error trigger:

function addNewCo(e) {
  var app=UiApp.getActiveApplication();
  var newCoName=e.parameter.newCoName;
  coSheet.appendRow([newCoName]);
  coSheet.sort(1,true);
  var coSheetValues=coSheet.getRange(2,1,coSheet.getLastRow()-1,coSheet.getLastColumn()).getValues();
  app.getElementById('coNameLB').clear().addItem(newCoName).addItem('').addItem('Select Company ---');
  for (i=0;i<coSheetValues.length;i++){ app.getElementById('coNameLB').addItem(coSheetValues[i][coSheetColNamesArray.indexOf('Company Name')]); }
  app.getElementById('popupPanel').setVisible(false);
  app.getElementById('GoBtn').setStyleAttribute('background','#2a9c3b').setEnabled(true);
  app.getElementById('processingLbl').setVisible(false);
  return app;
}

As I said above, the handler completes it's function, so why would this error be popping up at me?


This is getting really nuts. I removed any reference to the sheet after the append and sort, in other words I took out the getRange in the handler function altogether, but the error still keeps popping up!

function addNewCo(e) {
  var app=UiApp.getActiveApplication();
  var newCoName=e.parameter.newCoName;
  coSheet.appendRow([newCoName]);
  coSheet.sort(1,true);
  app.getElementById('coNameLB').clear().addItem(newCoName).addItem('').addItem('Select Company ---');
  app.getElementById('popupPanel').setVisible(false);
  app.getElementById('GoBtn').setStyleAttribute('background','#2a9c3b').setEnabled(true);
  app.getElementById('processingLbl').setVisible(false);
  return app;
}

I am not even calling a getRange, so how can the error be popping up still?


Unbelievable. Now I took out any mention of the spreadsheet from the handler, and I STILL get the error. What the heck Google?!? The doGet() function loads fine, the error only comes up using the handler - even when there is no mention of the spreadsheet - what in the world?!?:

function addNewCo(e) {
  var app=UiApp.getActiveApplication();
  var newCoName=e.parameter.newCoName;
  app.getElementById('coNameLB').clear().addItem(newCoName).addItem('').addItem('Select Company ---');
  app.getElementById('popupPanel').setVisible(false);
  app.getElementById('GoBtn').setStyleAttribute('background','#2a9c3b').setEnabled(true);
  app.getElementById('processingLbl').setVisible(false);
  return app;
}

I have stripped the handler function to just closing the popup and I still get the error.

function addNewCo(e) {
  var app=UiApp.getActiveApplication();
  app.getElementById('popupPanel').setVisible(false);
  return app;
}

Anyone from Google on here care to help?

1
I am now even getting this error from versions saved hours ago.user1783229

1 Answers

3
votes

Fixed it. I had a textbox as part of an array of fields getting other focushandlers where it shouldn't have been. Would be very helpful, Google, if you had a listing of your cryptic errors and their meaning somewhere and if the line number showed up on the error message dialogbox popup indicating where the problem is so we don't have to scour hundreds of line of code. It is ridiculous that a google search for an error message from a google apps script returns no results. 2 hours wasted.