Created
February 12, 2023 17:52
-
-
Save scottpdawson/2d80af45f18118477e413a70504d6f04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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