为了避免使用手机时无法“单击”GoogleSheets 中的按钮,我创建了一个 onEdit 触发器来操作一个函数,该函数在选中特定工作表上的单元格 D5 中的复选框时运行。 该脚本运行良好,但如果我取消选中该复选框,脚本将再次运行。 有什么办法可以防止这种情况发生吗?
谢谢
function onEdit(e) {
myfunction1(e)
}
function myfunction1(e) {
if (!e.value) return
if (e.value !== "TRUE") return
if (e.range.rowStart !== 5) return
if (e.range.columnStart !== 4) return
if (e.range.getSheet().getName() !== "Create New Orders") return
orderFromSheet()
e.range.uncheck()
}
我已经寻找答案,但未能找到解决方案。
如果您只是检查 D5 的值,我会这样做:
function onEdit(e) {
// A1 Notation lets you just check for the string value of cell 'D5'
if(e.range.getA1Notation() == "D5" && e.range.getValue() == true){
orderFromSheet()
// You don't really need to set the value programatically here,
// unless there is something I don't understand about the way
// you are interacting with your phone and Google Sheets...
e.range.setValue(true)
}
}