Google-sheets – Syncing Google Sheets to Google Calendar

google sheetsgoogle-apps-scriptgoogle-calendar

Automatically add a schedule from Google Sheets into Calendar

I followed the instructions in this video:
https://www.youtube.com/watch?v=MOggwSls7xQ

and it works fine. However, the one thing that the video doesn't include is capturing and syncing the event's description.

Here's the script below:

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

function scheduleShifts() {


/**
  Task 1) Open the Event Calendar.
  **/


  var spreadsheet = SpreadsheetApp.getActiveSheet();
  var calendarId = spreadsheet.getRange("C4").getValue();
  var eventCal = CalendarApp.getCalendarById(calendarId);

  /**
  Task 2) Pull each shift information into the code, in a form that the code can understand.
  **/

  var signups = spreadsheet.getRange("A8:C").getValues();

  /**
  Task 3) Do the Work!
  **/

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

    var shift = signups[x];

    var startTime = shift[1];
    var endTime = shift[2];
    var volunteer = shift[0];
    var des = shift[3]

    eventCal.createEvent(volunteer, startTime, endTime, des);
}
}

Best Answer

Please try adding the following:

eventCal.createEvent(volunteer, startTime, endTime, {description: des});

https://developers.google.com/apps-script/reference/calendar/calendar#createEvent(String,Date,Date,Object)