Reputation: 1
function doGet(){
try{
var html = HtmlService.createTemplateFromFile('index').evaluate().setTitle('Web App').setSandboxMode(HtmlService.SandboxMode.NATIVE);
var x = t;
} catch(error){
var errorSheet = SpreadsheetApp.openById('...MySpreadSheetID...').getSheetByName('errors');
var cell = errorSheet.getRange('A1').offset(errorSheet.getLastRow(), 0);
cell.setValue(new Date() + ' function doGet(): ' + error)
}
return html;
}
Why does the getRange() Method does not work.
It states that getRange() of null cannot be invoked?
Upvotes: -1
Views: 659
Reputation: 376
Your SpreadsheetApp.openById(...) refers to "...MySpreadSheetID...", which probably is not defined.
You need to provide a proper ID of a defined spreadsheet in your account.
/edit: Its either the Spreadsheet not defined or the sheet within your spreadsheet, which is not defined.
Upvotes: 0
Reputation:
The getRange() expects at least one argument (depending on the arguments configuration). Probably, there is no tab named errors
in your spreadsheet.
Suggestion:
If you want to add a new row at the next available row, you can use the appendRow() method, just consider this method expects an array of values. Your catch statement should look like this:
} catch(error){
var errorSheet = SpreadsheetApp.openById('...MySpreadSheetID...').getSheetByName('errors');
errorSheet.appendRow([new Date() + ' function doGet(): ' + error])
}
Upvotes: 1