Row Modified timestamp

Is there a clever way to make a row modified timestamp? This is so I can sort a list by date modified. The onEdit trigger doesn’t work since Glide updates the sheet with a script/api. Thanks in advance!

1 Like

Something like this.

1 Like

If you are using the built in edit function, you can use the date time special value.

1 Like

Use onchange instead. But, sometimes, it fired not on the single cell but on the range of cells.

This is the best way to handle it if he’s using the edit pencil in my opinion. Point the current datetime special value to a “Last edit” column and you’re set.

1 Like

This is what I ended up using, which has the added benefit of working on all of the sheets, because it only looks for a column with “Modified Date” in the first row (also, it won’t modify the first row):

function onChange(e) {

	const sheet = SpreadsheetApp.getActiveSheet()

	const rowIndex = (function() {
		switch (e.changeType) {
			case "EDIT":
				return sheet.getActiveCell().getA1Notation().replace(/\D/g, "").trim()
			case "INSERT_ROW":
				return sheet.getLastRow()
				throw new Error(`This function can't handle changeType: ${e.changeType}`)

	const column = sheet.getDataRange().getValues()[0].indexOf("Modified Date") + 1

	if (rowIndex != 1 && column !== 0)
		sheet.getRange(rowIndex, column).setValue(new Date())

NOTE: This works based on a trigger, so after adding this function to the project, you have to create an “On change” trigger to run it.

1 Like