Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9691

How do I stop script from reading rows more than once?

$
0
0

Running into an issue where the script is reading the same row more than once. For example, I run the script and it pushes row 1 to the calendar as intended. When I add more info in row 2 and run the script again, it will push info from row 1 again as well as row 2's info to the calendar. I have tried an already added function as well as adding another column I can mark once completed so the script is contained to new rows only. I am still a novice when it comes to scripts. Working only with simple scripts and manipulating them to suit the needs of the sheet. When it comes to adding/creating functions in a script is where I run into issues.

Here is the code and the link to the sheet.

function simpleSheetsToCalendar() {  var ss = SpreadsheetApp.getActiveSpreadsheet();  var sheet = ss.getSheetByName('Test Weekend Coverage/Calendar Push - New');  var lastRow = sheet.getLastRow();  Logger.log(lastRow);  var data = sheet.getRange(sheet.getLastRow(),1,1,6).getValues();  var title = data[0][0];  var eventDesc = data[0][1];  var eventLoca = data[0][2];  var startDate = data[0][3];  var endDate = data[0][4];  var attendees = data[0][5];  var masterCal = CalendarApp.getCalendarById('doordash.com_oi7od81qlvove73q1dgt013838@group.calendar.google.com');      masterCal.createEvent(title,new Date(startDate),new Date(endDate),{location:eventLoca,description:eventDesc,guests:attendees,sendInvites:true});  }

Viewing all articles
Browse latest Browse all 9691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>