Update and Delete Calendar Events

Once a calendar event is created, you can update its title, time, description, location, and other properties at any time using Apps Script. You can also delete events — individually or in bulk — based on title, date range, or any other criteria.

Updating an Event by ID

The most reliable way to update a specific event is by its ID:

function updateEventById() { var eventId = "YOUR_EVENT_ID"; var calendar = CalendarApp.getDefaultCalendar(); var event = calendar.getEventById(eventId); event.setTitle("Rescheduled Follow-up – Mark Chen (Enterprise Plan)"); event.setDescription("Rescheduled at customer request. New time confirmed via email."); // Reschedule to the next day var newStart = new Date(event.getStartTime().getTime() + 24 * 60 * 60 * 1000); var newEnd = new Date(event.getEndTime().getTime() + 24 * 60 * 60 * 1000); event.setTime(newStart, newEnd); Logger.log("Event updated: " + event.getTitle()); }

Updating Events Matching a Search Term

This reschedules all follow-up calls that contain a customer name:

function rescheduleCustomerFollowUp() { var calendar = CalendarApp.getDefaultCalendar(); var now = new Date(); var nextMonth = new Date(); nextMonth.setMonth(nextMonth.getMonth() + 1); var events = calendar.getEvents(now, nextMonth, { search: "Mark Chen" }); events.forEach(function(event) { // Push each matching event forward by 3 days var newStart = new Date(event.getStartTime().getTime() + 3 * 24 * 60 * 60 * 1000); var newEnd = new Date(event.getEndTime().getTime() + 3 * 24 * 60 * 60 * 1000); event.setTime(newStart, newEnd); Logger.log("Rescheduled: " + event.getTitle() + " → " + newStart); }); }

Updating Event Status When a Deal Closes

When a deal is marked Closed in the Sales Tracker, update the corresponding follow-up event title to reflect this:

function markFollowUpsAsClosed() { var sheet = SpreadsheetApp .getActiveSpreadsheet() .getSheetByName("Sales Tracker"); var data = sheet.getRange(2, 1, sheet.getLastRow() - 1, 7).getValues(); // Columns: [Customer Name, Email, Product, Amount, Region, Sales Rep, Status] var calendar = CalendarApp.getDefaultCalendar(); var now = new Date(); var nextMonth = new Date(); nextMonth.setMonth(nextMonth.getMonth() + 1); data.forEach(function(row) { var customerName = row[0]; var status = row[6]; if (status !== "Closed") return; var events = calendar.getEvents(now, nextMonth, { search: customerName }); events.forEach(function(event) { if (event.getTitle().indexOf("Follow-up") !== -1) { event.setTitle("[CLOSED] " + event.getTitle()); event.setColor(CalendarApp.EventColor.GREEN); Logger.log("Updated event for closed deal: " + customerName); } }); }); }

Deleting a Specific Event

function deleteEventById() { var eventId = "YOUR_EVENT_ID"; var calendar = CalendarApp.getDefaultCalendar(); var event = calendar.getEventById(eventId); if (event) { event.deleteEvent(); Logger.log("Event deleted."); } else { Logger.log("Event not found."); } }

Deleting All Events Matching a Search

This cancels all follow-up events for a specific customer — useful when a deal is lost:

function cancelFollowUpsForCustomer(customerName) { var calendar = CalendarApp.getDefaultCalendar(); var now = new Date(); var nextMonth = new Date(); nextMonth.setMonth(nextMonth.getMonth() + 1); var events = calendar.getEvents(now, nextMonth, { search: customerName }); events.forEach(function(event) { event.deleteEvent(); Logger.log("Deleted: " + event.getTitle()); }); } // Example usage cancelFollowUpsForCustomer("Mark Chen");

Available Event Color Constants

CalendarApp.EventColor.PALE_BLUE // Light blue CalendarApp.EventColor.PALE_GREEN // Light green CalendarApp.EventColor.MAUVE // Purple CalendarApp.EventColor.PALE_RED // Red CalendarApp.EventColor.YELLOW // Yellow CalendarApp.EventColor.ORANGE // Orange CalendarApp.EventColor.CYAN // Teal CalendarApp.EventColor.GRAY // Gray CalendarApp.EventColor.BLUE // Blue CalendarApp.EventColor.GREEN // Green CalendarApp.EventColor.RED // Red