0

I am attempting to have users answer questions in a Google Form, that is linked to a Google Sheet, and I have an Apps Script that will create a Google Calendar Event. I have an "On form submit" trigger setup so each time a new form is submitted, my App Script will run. However I'm a total newb and don't know how to make my script only pull data from the newly added row. Here is my script:

function createCalendarEvent() {
  let RequestTimeOffCalendar = CalendarApp.getCalendarById("c_lb66r3ruc5jsg84m0vjv4tao04@group.calendar.google.com");
  let sheet = SpreadsheetApp.getActiveSheet();

let schedule = sheet.getDataRange().getValues();
schedule.splice(0, 1);

schedule.forEach(function(entry) {
  RequestTimeOffCalendar.createEvent(entry[1], entry[2], entry[4]);
  });
}
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    Welcome to [so] Use the form submit event object for spreadsheets. (https://developers.google.com/apps-script/guides/triggers/events. We already have several questions and answers that use it. – Rubén Sep 13 '22 at 15:22
  • can onEdit be used to modify spreadsheet data using a form? – Nicholas Saunders Oct 09 '22 at 05:45

0 Answers0