Set variable calendarID in Google Apps Script

151 views Asked by At

I'm having some trouble setting a variable CalendarID in the Google Apps Script for my spreadsheet (using sheet to sync to gcal).

So far I've come to:

enter code here

  var sheet = SpreadsheetApp.getActiveSheet();
  var range = sheet.getRange(2,6);
  var calendarId = sheet.range.getValue()

enter code here

With my gcal ID set in "G2" (hence getRange(2,6)

2

There are 2 answers

0
peekolo On

Firstly, G2 should be sheet.getRange(2,7) because A1 is (1,1). You can also use sheet.getRange("G2").

Then your last line should be var calendarId = range.getValue() since range is separately user defined variable and not a property of sheet in this case.

0
Thomas On

i found the culprit. We need getDisplayValue() instead of getValue()