Google Sheets 应用程序脚本:当通过触发器运行 onChange 函数时,e.range 为 null
这个问题让我被禁止提问...我做错了什么?!我真的不明白。
我正用头撞键盘。
这看起来应该很简单......但我仍然收到错误:
类型错误:无法读取未定义的属性“getNumColumns”** 在 onChange(checkBoxes:5:20)
目标是单击复选框,获取日期戳,但我还需要检查列标题(第 4 行)以确定下一步要运行什么函数... 但是,我无法做到这一点,因为我需要知道触发该函数的单元格的列。
function onChange(e) {
const range = e.range;
Logger.log(range.getNumColumns());
};
/**Trigger:
Head:= Deployment
Event:= From spreadsheet - On change
Function:= onChange
Error rate:= 100% */
从技术上讲,我可以使用 activecell
但我担心用户不可靠,如果他们选中 col:1 中的复选框然后单击 col:2,会发生什么情况 activecell
返回列:1,还是2?
我尝试了多种组合来解决这个问题,但每次它说“无法读取未定义的属性'getNumColumns'”时,
我都尝试了以下方法:
e.range.columnStart
This question got me banned from asking questions... what did I do wrong?! I really don't understand.
I am bashing my head against my keyboard.
This seems like it should be simple... but I continue to get the error:
TypeError: Cannot read property 'getNumColumns' of undefined**
at onChange(checkBoxes:5:20)
The goal would be to click a check box, get a date stamp, but I need to also check the column header (Row 4) to determine what function to run next...
However, I can not get that far because I need to know the column of the cell that triggered the function.
function onChange(e) {
const range = e.range;
Logger.log(range.getNumColumns());
};
/**Trigger:
Head:= Deployment
Event:= From spreadsheet - On change
Function:= onChange
Error rate:= 100% */
Technically speaking I can use activecell
but I am concerned that users are unreliable, what happens if they check a check box in col:1 then click to col:2, will activecell
return col:1, or 2?
I have tried a verity of combinations to solve this, but each time it says "Cannot read property 'getNumColumns' of undefined"
I have tried the following:
e.range.columnStart
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有时还有其他的,比如授权级别和用户信息
There are others like authorization level and user information sometimes