I manage bookings for my business on Google Spreadsheet. I discovered a wonderful script to update my calendar according to the bookings on the spreadsheet: https://github.com/Davepar/gcalendarsync So one row = one booking = one event in the calendar. It works perfectly, but I need a new feature.
As of right now, the script will update one specific calendar, and I would like to update two separate calendars, depending on the value of a specific column.
Example: Let's say I manage a limo business, and I have two limos, a blue one and a red one. I put the bookings in a worksheet, specifying for each row if i'll assign the blue or red limo. I would like to have 2 separate calendars to check the availability of each one separately.
I'm no programmer, but I looked around and apparently this can be done fairly easily, by adding a function: "if value of column C is "blue", assign this calendar ID, if value of column C ir "red", assign this calendar ID." I just don't know exactly how to do it.
So, here is the script: https://raw.githubusercontent.com/Davepar/gcalendarsync/master/gcalendarsync.js
According to me, what has to be modified is this:
var calendarId = '<your-calendar-id>@group.calendar.google.com';
// Synchronize from spreadsheet to calendar.
function syncToCalendar() {
// Get calendar and events
var calendar = CalendarApp.getCalendarById(calendarId);
if (!calendar) {
errorAlert('Cannot find calendar. Check instructions for set up.');
I replaced by:
var calendarId1 = 'calendaridofbluelimo@group.calendar.google.com';
var calendarId2 = 'calendaridofredlimo@group.calendar.google.com';
// Synchronize from spreadsheet to calendar.
function syncToCalendar() {
// Get calendar and events
var calendar = CalendarApp.getCalendarById(calendarId1);
if (!calendar) {
errorAlert('Cannot find calendar. Check instructions for set up.');
I haven't modified much at all, I still need to add the function that determines which calendar has to be modified.
I tried to do it according to this response: Create events in multiple Google Calendars from Spreadsheet But I couldn't figure it out (it is for a different script)
Note: I removed all the "Calendar to Spreadsheet" syncing function - I don't want a modification on the calendar to affect the spreadsheet.
Any help would be very appreciated!
Thanks