Error: You have been creating or deleting too many calendars or calendar events in a short time

52 Views Asked by At

Checking if anyone knows how to resolve this.

I created a script in Google Sheets to create calendar event automatically based on this (https://workspace.google.com/blog/productivity-collaboration/g-suite-pro-tip-how-to-automatically-add-a-schedule-from-google-sheets-into-calendar) and added 5 data (start, end, title, email (guests), location)

However upon saving and running the script, it syncs 1 time after that these 2 issues happen:

  1. error comes up: "Exception: You have been creating or deleting too many calendars or calendar events in a short time. Please try again later." - newly added row are not created as calendar event
  2. email address wasn't included in the guest for the event

I looked up on this website and few other places and saw some people gave suggestion to place Utilities.sleep(3000); to resolve however no matter which part that i place this, the error still happens

below is the code if anyone can help me...Thanks in advance!

function scheduleShifts() {
/**
    Task 1) Open the Event Calendar
**/
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("A1").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("A3:E").getValues();

/**
    Task 3) Do the work!
**/
for (x=0; x<signups.length; x++) {

  var shift = signups[x];

  var startTime = shift[0];
  var endTime = shift[1];
  var title = shift[2];
  var guests = shift[3]
  var location = shift[4];
  
  eventCal.createEvent(title, startTime, endTime, {
    guests:guests,
    location: location
  });
  
}
}
/**
   Task 4) Make it easy to use.
**/
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sync to Calendar')
      .addItem('Schedule shifts now','scheduleShifts')
      .addToUi();
 
}

embed Utilities.sleep(3000); as some suggested but does not work

1

There are 1 best solutions below

0
On

This is a limitation in Google calendar itself and not related to the api.

Wait until midnight west coast USA and it will reset.