While following the tutorial here: https://developers.google.com/apps-script/articles/building-sites-app-part1
I have the sample code copied in and modified etc. When I try to run it I get the error:
TypeError: Cannot call method "getLastRow" of null. (line 327)
Error.
Here are lines 326, 327 from that page:
326) var sheet = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName("TimeBooking"); 327) var lastRow = sheet.getLastRow();
If I edit the string for .getSheetByName to make it wrong on purpose, then I get an error on line 326 telling me it can't find the sheet. Good, it should fail that test. If I make sure the line 326 is correct, it runs silently with no errors, but line 327 puts out the null error.
If the sheet object is invalid, why doesn't line 326 warn me about it?
Note I get the same null error whether I run this code directly in the apps editor, or whether I publish the URL and run it from my sites page as a google Apps widget..
Any ideas? I'm trying to learn the basics, and got stumped on my first "copy and paste" of an example (lol!)