【发布时间】:2021-04-29 18:09:07
【问题描述】:
我正在尝试创建超过 1 个时间戳,但是当您尝试复制一个函数时,我不能,因为 'tf' 已经在使用中。我收到此错误:
语法错误:SyntaxError: Identifier 'tf' has been declared line: 16 file: START TIMESTAMP.gs
这是我目前所拥有的:
function onEdit(e) {
addTimestamp(e)
}
function addTimestamp(e) {
const activeSheet = e.source.getActiveSheet()
const modifiedCell = e.range
const tf = activeSheet.createTextFinder("Start")
tf.matchEntireCell(true)
const cellStart = tf.findNext()
const row = cellStart.getRow()
const col = cellStart.getColumn()
// guard statements
if(!activeSheet.getSheetName().toString().startsWith("TASKS")) return
if(!(modifiedCell.getColumn() === col && modifiedCell.getRow() > row)) return
if(e.value === "TRUE"){
modifiedCell.offset(0,1).setValue(new Date())
} else {
modifiedCell.offset(0,1).clearContent()
}
//SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().offset()
}
【问题讨论】:
标签: sql google-apps-script google-sheets timestamp