He estado trabajando en el script de esta aplicación tratando de automatizar datos de una hoja de Google para crear eventos en Google Calendar. Intenté cambiar las comillas de simple a doble y viceversa. He comprobado mi () una y otra vez. No puedo ver lo que he hecho que me da el error de sintaxis. Si puedes verlo, por favor dímelo. Esto me está volviendo loco.
function AutomateCalendarEvent() { let sheet = SpreadsheetApp.getActiveSheet(); let pqCalendar = CalendarApp.getCalendarById("zyxwvutsrqp"); let reservation = sheet.getRange("C2:E1105").getValues(); reservation.splice(0, 1); let rows = sheet.getDataRange().getValues(); rows.forEach(function (row, index) { if (index === 0) return; if (row[C3]) return; pqCalendar.createAllDayEvent("Last Name"C2:C, "Arrival Date"D2:D, "Departure Date"E2:E); }) } function AutomateCalendarEvent() { let sheet = SpreadsheetApp.getActiveSheet(); let pqCalendar = CalendarApp.getCalendarById("zyxwvutsrqp"); let reservation = sheet.getRange("C2:E1105").getValues(); reservation.splice(0, 1); let rows = sheet.getDataRange().getValues(); rows.forEach(function (row, index) { if (index === 0) return; if (row[C3]) return;//C3 should be an index between 0 and 2 pqCalendar.createAllDayEvent("Last Name"C2:C, "Arrival Date"D2:D, "Departure Date"E2:E);//parameters should be a string followed by two dates //this is not the way insert parameters into above command. Ranges do not return values }) }Suponiendo que sus datos son los siguientes
Intente (para evitar duplicados, el ID del evento se almacena aquí en la columna AI fr instancia)
function AutomateCalendarEvent() { let sheet = SpreadsheetApp.getActiveSheet(); let swCalendar = CalendarApp.getCalendarById("***********@gmail.com"); let rows = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues(); rows.filter(row => row[2] != '').forEach(function (row, index) { if (index === 0) return; if (row[34] == '') { // AI try { sheet.getRange('AI' + (+index + 1)).setValue(swCalendar.createAllDayEvent(row[2], row[3], row[4]).getId()) } catch (e) { console.log(e) } } }) }createAllDayEvent(título, fecha de inicio, fecha de finalización, {opciones})