Skip to content

Instantly share code, notes, and snippets.

@empeje
Created August 4, 2023 16:42
Show Gist options
  • Save empeje/db4997c0040139454ca7004c473c5015 to your computer and use it in GitHub Desktop.
Save empeje/db4997c0040139454ca7004c473c5015 to your computer and use it in GitHub Desktop.
App Script
function onEdit(e) {
updateTimestamp(e) // modularize in separate function and add it in the onEdit hook
}
function updateTimestamp(e) {
var ss=SpreadsheetApp.getActiveSpreadsheet();
if(ss.getSheetName() === "Jobs") { // change your sheet name here
ss.setCurrentCell(ss.getRange(`C${ss.getActiveCell().getRow()}`)) // change C to something else if the column is different
var activeCell = ss.getCurrentCell()
var now = new Date()
console.log(`Set date to ${now.toDateString()}`)
activeCell.setValue(now.toDateString())
ss.setCurrentCell(ss.getActiveCell())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment