待办事项列表任务列表Google 表格/脚本访问链接
使用 onEdit for checkbox=true (Col D : Row 6) 向下,到右 3 列 (G5) 的偏移量应该返回新的 date() 作为选中行的设置值。这不会返回错误并且执行失败
函数 onEdit 返回,没有任何日志或错误(控制台日志),但“日期时间戳”未在复选框(True)时推送或添加到预期的列 G6、g7、g8 ...等中
函数 addTimeStamp 返回错误“TypeError:无法读取未定义的属性(读取“源”) 在addTimeStamp(代码:6:25)“
function onEdit(e) {
addTimeStamp(e)
}
function addTimeStamp(e) {
const activeSheet = e.source.getActiveSheet()
const modifiedCell = e.range
const tf = activeSheet.createTextFinder("Done") // Find text in sheet for activerange
tf.matchEntireCell(true)
const cellDone = tf.findNext()
const row = cellDone.getRow()
const col = cellDone.getColumn()
// console.log(row)
// console.log(col)
if(!(modifiedCell.getColumn() === col && modifiedCell.getRow() > row)) return // guarded statement
// console.log("I am here")
console.log(e.value)
if(e.value === "TRUE") {
modifiedCell.offset(0,3).setValue(new Date())
console.log(modifiedCell.value)
console.log(setValue)
}
// SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().createTextFinder().findNext()
// SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().offset().setValue()
}