Google脚本中onSubmit的事件对象为空 [英] Event object of onSubmit is empty in Google script
问题描述
我有一个链接到Google表格的Google表单.在该电子表格中,我有包含此代码的代码
I have a Google form linked to a Google sheet. In that spreadsheet I have code that have this
function onSubmit(e){
Logger.log(e)
Logger.log("Call onSubmit")
}
触发器设置如下
Project: Spreadsheet's scritp
Deployment:Head
Event:From spreadsheet - On form submit
Function:onSubmit
因此,每当我提交表单时,日志就会显示
So whenever I submit the form, the log shows
[object Object]
Call onSubmit
该表格有很多问题,不能为空.在阅读文档时,似乎事件对象具有许多信息.我的设置有问题吗?我已采取措施读取数据表中的响应,但这并不理想.太多的事情必须手动调用和/或定义.
The form has many questions, not an empty form. As I read the documentation, it seems like the event object has many information. Is there something wrong with my setup? I have resorted to read responses in the data sheets but that's not ideal. Too many things have to call and/or defined manually.
推荐答案
记录器有故障,不建议直接依赖于调试器中看到的内容.
The logger is buggy and it is not recommended to rely directly on what you see in the debugger.
-
始终使用
console
类而不是Logger
始终 JSON.stringify()
您要记录的任何内容:
Always JSON.stringify()
anything that you're going to log:
console.log(JSON.stringify(e));
最后一个应该解决您的问题. [object Object]
是在对象上调用 toString()
的结果,因为记录器无法直接显示对象.
The last one should fix your problem. [object Object]
is the result of calling toString()
on a object, as the logger is incapable to displaying a object directly.
const obj = {a:1};
console.log(obj.toString());//[object Object]
console.log(JSON.stringify(obj));//'{"a":1}'
这篇关于Google脚本中onSubmit的事件对象为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!