0

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);
}
}
1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.