Skip to content

Instantly share code, notes, and snippets.

@scottpdawson
Created February 12, 2023 17:52
Show Gist options
  • Save scottpdawson/2d80af45f18118477e413a70504d6f04 to your computer and use it in GitHub Desktop.
Save scottpdawson/2d80af45f18118477e413a70504d6f04 to your computer and use it in GitHub Desktop.
function findRow(searchVal) {
// find row containing the event's timestamp
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var searchDate = new Date(searchVal);
for (x = 0; x < data.length; x++) {
var thisDate = new Date(data[x][0]);
if (thisDate.getTime() === searchDate.getTime()) {
return x + 1;
}
}
return "not found";
}
// get the timestamp for the current event
var timestamp = order[0];
// find the row corresponding to the timestamp
var spreadsheetRow = findRow(timestamp);
// write the newly-written event's ID to column R of the spreadsheet
spreadsheet.getRange('R' + spreadsheetRow).setValue(newEvent.getId());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment