无法将日历事件从 Google 表格获取到日历

问题描述 投票:0回答:0

我正在尝试将我在 Google 工作表中的日程表中的日历事件设置为 Google 日历,以避免手动进行。

I developed a code and it is giving me error message

Here is how my sheet looks like

function scheduleShifts() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendar_ID = spreadsheet.getRange("A1").getValue();
var eventCal = CalendarApp.getCalendarById(calendar_ID);

var events = spreadsheet.getRange("H2:I996").getValues();

for (x=0; x<events.length; x++) {

  var schedule = events[x];

  var startTime = schedule[7];
  var endTime = schedule[8];
  var name = schedule[2];
  var address = schedule [3];
  var phone = schedule [4];
  var description = schedule[5];
  var comments = schedule[6];

  eventCal.createEvent(address, startTime, endTime);

  }
  
}

function onOpen() {

  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sync to Calendar')
      .addItem('Schedule shifts now', 'scheduleShifts')
      .addToUi();
}

javascript google-apps-script google-calendar-api google-workspace workspace
© www.soinside.com 2019 - 2024. All rights reserved.