Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add a description into google calendar from google sheet

I’m creating events in a google calendar via a worksheet in google sheets (I use Gsuite / google workspace). I have the following script which works well, however, I need the description to go into google calendar as well. At the moment only the title, start, end and location are going over.

How can I edit my script so that the description goes into the event?

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function create_Events(){

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Test");
  var last_row = sheet.getLastRow();
  var data = sheet.getRange("A1:E" + last_row).getValues();
  var cal = CalendarApp.getCalendarById("Joe@email.com.au");
  //Logger.log(data);

  for(var i = 0;i< data.length;i++){
    //index 0 =
    var event = CalendarApp.getDefaultCalendar().createEvent(data[i][0],
    new Date(data[i][1]),
    new Date(data[i][2]),
    {location: data[i][3]});
 Logger.log('Event ID: ' + event.getId());

    
  }

}

>Solution :

Try it this way:

function create_Events() {
  var ss = SpreadsheetApp.getActive();
  var sh = ss.getSheetByName("Test");
  var vs = sh.getRange("A1:E" + sh.getLastRow()).getValues();
  var cal = CalendarApp.getCalendarById("Joe@email.com.au");
  vs.forEach(([t, s, e, l, d]) => {
    cal.createEvent(t, new Date(s), new Date(e), { description: d, location: l });
  });
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading