Google calendar sync with Google spreadsheet.

76 views
Skip to first unread message

Fion Ku

unread,
Oct 21, 2023, 3:38:55 PM10/21/23
to Google Apps Script Community
Hi, i would like to create a simple integration. When every time i keep in the date n time n title, in my spreadsheet...it will create event in my google calendar. Once the event appear in google calendar, it will update the status as "done" in the google spreadsheet, with embedded url that can direct me to google calendar show on particular date once i clicked the "done" word. 

I got following script. Can save, managed to authorize , but unable to RUN . It show error at this part:
var sheet = e.range.getSheet();
var range = e.range;

Can anyone enlighten me?

function onEdit(e) {
// Get the spreadsheet and the range that was edited
var sheet = e.range.getSheet();
var range = e.range;

// Check if the edited range is in the "Date & Time" column
if (range.getColumn() !== 2) {
return;
}

// Get the event title, date, time, end date, time, and description from the spreadsheet
var eventTitle = range.getValue();
var eventDate = range.offset(0, 1).getValue();
var eventTime = range.offset(0, 2).getValue();
var eventEndDate = range.offset(0, 3).getValue();
var eventEndTime = range.offset(0, 4).getValue();
var eventDescription = range.offset(0, 5).getValue();

// Create a new event in Google Calendar
var event = CalendarApp.createEvent(eventTitle, eventDate, eventTime, eventEndDate, eventEndTime, eventDescription);

// Set a reminder for the event
event.addReminder(30);

// Update the status column in the spreadsheet to "Done" and add an embedded link to the event in Google Calendar
range.offset(0, 1).setValue("Done");
var eventUrl = event.getUrl();
range.offset(0, 1).setHyperlink(eventUrl, eventTitle);
}

Bennett, Scott

unread,
Oct 21, 2023, 5:11:48 PM10/21/23
to google-apps-sc...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/27934b80-6dda-486c-8d46-7231b05bd651n%40googlegroups.com.


--
Scott Bennett
Data and Assessment Coordinator/Math Teacher
Bradley-Bourbonnais Community High School

Reply all
Reply to author
Forward
0 new messages