Hello,
I am working on a Google Apps Script project that updates Google Calendar events in batches using the LongRun library. The first batch updates successfully, but from the second batch onwards, event IDs are not found in the sheet, causing events to be skipped.
Issue:
Subsequent batches return the following error:
Warning: Event ID <id> not found in sheet. Skipping event.
Even though the event IDs exist in Column A, they are not recognized after resuming.
Code for Retrieving Event IDs:
function getEventsToUpdate(sheet) { var updateColumnIndex = 8; // Column I (checkbox column) var eventIdColumnIndex = 0; // Column A (event ID column) var data = sheet.getDataRange().getValues(); var eventsToUpdate = []; for (var i = 1; i < data.length; i++) { if (data[i][updateColumnIndex] === true) { var eventId = data[i][eventIdColumnIndex].toString().trim(); if (eventId.endsWith("@google.com")) { eventId = eventId.replace("@google.com", ""); } eventsToUpdate.push(eventId); } } Logger.log("Events to update: " + JSON.stringify(eventsToUpdate)); return eventsToUpdate; }
What Has Been Checked:
- Event IDs are present in Column A before Batch 2 starts.
- Event IDs are stored without the suffix @Google .com before sending to the API.
- Logged event IDs appear correct before processing.
Questions:
- Why does Batch 1 update successfully, but Batch 2 fails to find event IDs?
- Should each batch retrieve event IDs fresh from the sheet instead of using stored values?
- Is there a better way to persist event IDs across batch executions in LongRun?
Any insights or recommendations would be greatly appreciated. Thank you!