Google Sheets onEdit(e) TypeError:无法读取属性 [英] Google Sheets onEdit(e) TypeError: cannot read property

查看:24
本文介绍了Google Sheets onEdit(e) TypeError:无法读取属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现 Google 表格的 onEdit(e) 简单触发器.每次我尝试执行一个简单的函数,例如:

I'm trying to implement the onEdit(e) simple trigger of Google Sheets. Everytime I try execute even a simple function such as:

function onEdit(e){
  Logger.log(e.oldValue);
}

我收到以下错误:

我的步骤:

我试过关注这两个视频,但没有成功:

I've tried following these two videos with no success:

https://www.youtube.com/watch?v=eWn_JxPSbds

https://www.youtube.com/watch?v=L1_nIhiVc5M

解决方案

感谢@JPV 和@TheMaster 提供两个潜在的解决方案:

Thanks to @JPV and @TheMaster for the two potential solutions:

我查看的是日志"而不是Stackdriver 日志".

I was viewing the "Logs" and not the "Stackdriver Logging".

看来您需要禁用 V8 才能在 Logs 中查看它,但需要 Stackdriver Logging 才能在 V8 中查看它.

It seems you need to disable the V8 to view it in Logs, but need the Stackdriver Logging to view it with V8.

至少我是这样

编辑两个

以下是解决问题的文档:

Here's the documentation where the issue is addressed:

https://developers.google.com/apps-script/guides/v8-runtime#ui_changes_for_logging

如果您的脚本使用 Rhino 运行时,在 Apps 脚本编辑器中选择查看 > 日志只会显示您最近由 Logger 服务写入的日志.您必须选择查看 > Stackdriver Logging 才能查看使用控制台类写入的日志."

"If your script uses the Rhino runtime, selecting View > Logs in the Apps Script editor only shows you recent logs written by the Logger service. You must select View > Stackdriver Logging to see logs written with the console class."

推荐答案

V8 没什么问题.该错误是因为您之前通过单击运行按钮直接运行了脚本.这导致了错误并被记录了下来.编辑时,它会记录到 view>stackdriver logging.但是之前的错误会显示给您.您正在查看旧日志.

Nothing is wrong with V8. That error is because you ran the script directly by clicking run button before. That caused the error and was logged. When you edit, it is logged to view>stackdriver logging. But the previous error is shown to you. You're looking at old logs.

根据官方文档

对于使用 V8 运行时的脚本,脚本编辑器视图 > 日志菜单项显示 当前会话中最近执行的记录器和控制台结果

For scripts using the V8 runtime, the script editor View > Logs menu item shows both Logger and console results for the most recent execution in the current session

只有当前会话日志可用于查看>日志.要访问以前的会话日志或未通过在当前会话中直接运行函数记录的日志,请使用 View > Stackdriver Logging....

Only current session logs is available to View>Logs. To access previous session logs or logs logged not by running a function directly in the current session, use View > Stackdriver Logging ....

这篇关于Google Sheets onEdit(e) TypeError:无法读取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆