在 onFormSubmit 中使用 e.values [英] Using e.values with onFormSubmit

查看:17
本文介绍了在 onFormSubmit 中使用 e.values的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,所以如果这是一个愚蠢的问题,请原谅我.

I'm brand new at this so please excuse me if this is a silly question.

我正在使用谷歌脚本根据从谷歌表单提交的答案进行更改.我有一个测试函数,我一直在使用它来在脚本编辑器中正确使用它,并且它运行良好.但是,当使用 onFormSubmit 触发器从 e.values 获取变量结果时,它没有做任何事情.我已经为项目定义了触发器,并且可以在当前项目的触发器"窗口中看到确认,所以它不可能是那样的.

I'm using google script to carry out a change based on the submitted answer from a google form. I've got a test function I've been using to get it right in the script editor and it works perfectly. When using the onFormSubmit trigger instead though, getting the variable result from e.values, it isn't doing anything. I've defined the trigger for the project and can see that confirmed in the 'Current Project's Triggers' window so it can't be that.

这是测试功能代码:

function Test_form_submit() {
   var ss = SpreadsheetApp.getActiveSpreadsheet()
   var sheet = ss.getSheetByName("Group Totals")
   SpreadsheetApp.flush()
   var their_choice1 = "Group 5: Thursday 6-8pm"
   var r = find_limits("C3:E7", their_choice1)
   var count = r[0]
   var limit = r[1] 
   check_availability("545507554", count, limit, their_choice1)

}

这是我的触发函数代码:

This is my trigger function code:

function onFormSubmit(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName("Group Totals")
  SpreadsheetApp.flush()
  var their_choice1 = e.values[3]
  var r = find_limits("C3:E7", their_choice1)
  var count = r[0]
  var limit = r[1] 
  check_availability("545507554", count, limit, their_choice1)

}

我想要的他们的选择在电子表格的 D 列中,所以我相信 e.values[3] 是正确的选择.我不明白为什么什么都没有发生.

The choice of theirs I'm wanting is in column D on the spreadsheet so I believe e.values[3] is the right thing to use. I can't understand why nothing is happening.

我也尝试添加一行 logger.log(e.values[3]) 但我查看时日志是空白的.

I tried adding a line of logger.log(e.values[3]) as well but the log is blank when I look.

任何帮助将不胜感激!

推荐答案

作为对 Amit 答案的补充,您可以使用 onFormSubmit 触发器来检查 eventInfo 中返回的所有值和参数像这样的声明:

As a complement to Amit's answer, you can check all the values and parameters returned in the eventInfo coming with the onFormSubmit trigger by using a statement like this :

  Logger.log(e);

这将显示如下内容:

(此处显示的值来自我使用垃圾"值的未使用形式;-) 但实际看到结构就足够了.)

(the values shown here come from an unused form that I had with "garbage" values ;-) but it is sufficient to actually see the structure.)

这篇关于在 onFormSubmit 中使用 e.values的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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