Last active
October 31, 2019 16:53
-
-
Save abrahamjuliot/0cd9c576d24b314859f8d6bf5622fe10 to your computer and use it in GitHub Desktop.
Log on edit
This file contains 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 onEdit(e){ | |
var sheetName = 'Daily Log' | |
var activeSheet = e.source.getActiveSheet() | |
if (activeSheet.getName() == sheetName) { | |
var seconds = 1000 | |
var row1 = 2 | |
var signCol = 4 | |
var whenSigned = SpreadsheetApp.newFilterCriteria().setHiddenValues(['TRUE']).build() | |
var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName) | |
var colEdited = e.range.getColumn() | |
var rowEdited = e.range.getRow().toFixed(0) | |
var timeStampCell = activeSheet.getRange( ('E'+rowEdited)) | |
var returnCell = activeSheet.getRange( ('D'+rowEdited)) | |
var didSign = (colEdited == signCol) | |
if(didSign) { | |
var isReturned = returnCell.getValue() | |
if (!isReturned) { timeStampCell.setValue('')} | |
else if (isReturned) { | |
var today = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'EEE MM/d @h:mm a') | |
timeStampCell.setValue(today) | |
} | |
Utilities.sleep(10*seconds) | |
activeSheet.getFilter().setColumnFilterCriteria(signCol, whenSigned) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment