DEV Community

Discussion on: Submit a Form to a Google Spreadsheet

Collapse
 
bobymarley profile image
BobyMarley • Edited

Hi Omer. I get error TypeError: Cannot read property 'getId' of null
Please tell me what is causing this error. Thnks!
drive.google.com/file/d/1bIhcizg8C...

Collapse
 
phillip_cantu_7592a0a0270 profile image
Phillip Cantu

I solved it with ChatGPT. Replace the beginning code to:
var sheetId = 'YOUR_SPREADSHEET_ID'; // Replace 'YOUR_SPREADSHEET_ID' with the actual ID of your Google Sheet
var sheetName = 'Sheet1'; // Replace 'Sheet1' with the name of your sheet if it's different

function doPost(e) {
var lock = LockService.getScriptLock();
lock.tryLock(10000);

try {
var doc = SpreadsheetApp.openById(sheetId); // Open the spreadsheet by ID
var sheet = doc.getSheetByName(sheetName);
THE REST OF THE CODE IS THE SAME
So the difference here is that you're putting the exact Google Sheet's ID

Collapse
 
phillip_cantu_7592a0a0270 profile image
Phillip Cantu

Same! Did you solve it?