Google Apps脚本无法使用表单提交的事件对象 [英] Event Object for Form Submit on Google Apps Script Not Working

查看:79
本文介绍了Google Apps脚本无法使用表单提交的事件对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习Google App脚本。我有一个问题的表单。然后我为响应创建了一个新的电子表格。然后从表单我去脚本编辑器。我为函数onSubmit(e)安装了一个新的触发器。

我想修改电子表格以获取回复。事件对象应该在刚刚添加的范围内传递。但每次我提交表单时,电子表格中都没有发生任何事情。

  function onSubmit(e){
var range = e.range;
range.setNote('changed');
}


解决方案

事实上,Bayani,I认为这两个触发器都起作用。问题是,当触发器处于表单中时,触发函数尝试在Google Forms服务使用提交的表单数据更新之前尽快读取电子表格。 (对不起,我添加了一个新的答案,但我的声望得分不允许我添加评论 - 非常抱歉,因为当我写这个答案时,我不小心点击了你的答案进行编辑,并将从改为在:请,只是拒绝我的编辑)。


I am trying to learn Google App Scripts. I have a form with one question. Then I created a new spreadsheet for the responses. Then from the form I went to the script editor. I installed a new trigger for the function onSubmit(e).

I wanted to modify the spreadsheet for responses. The event object should pass in the range that was just added. But every time I submit the form nothing happens in the spread sheet. I have the code below.

function onSubmit(e){
     var range = e.range;
     range.setNote('changed');
}

解决方案

In fact, Bayani, I think the trigger works from both. The thing is when the trigger is in the form, the triggered function tries to read the spreadsheet too soon, before Google Forms service update it with the submitted data of the form. (Sorry for adding a new answer, but my reputation score doesn't allow me to add comments yet - And very sorry because when I was writing this answer I accidentally clicked in your answer for editing and changed an "from" to an "in": please, just reject my edit).

这篇关于Google Apps脚本无法使用表单提交的事件对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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