通过onFormSubmit使用e

通过onFormSubmit使用e

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

问题描述

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



我使用谷歌脚本来执行基于从Google表单提交了答案。
我已经有了一个测试函数,我一直使用它在脚本编辑器中正确使用它,并且它完美地工作。
当使用onFormSubmit触发器时,虽然从e.values获取变量结果,但它没有做任何事情。我已经为项目定义了触发器,并且可以在当前项目的触发器窗口中看到确认,所以它不能这样。



这是测试功能代码:

 函数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)

}

这是我的触发器函数代码:

<$ p $
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]是正确的选择。
我不明白为什么什么事情都没有发生。

我试着添加一行logger.log(e.values [3]),但是日志是空白的,当我看。



任何帮助将不胜感激!

解决方案

作为Amit答案的补充,您可以使用类似下面的语句来检查在带有onFormSubmit触发器的 eventInfo 中返回的所有值和参数:

  Logger.log(e); 

这将显示如下所示:



(显示的值这里来自一个我用垃圾值的未使用过的形式;-)但实际上看到这个结构就足够了。)


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

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.

This is the test function code:

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)

}

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.

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

Any help would be much appreciated!

解决方案

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);

This will show something like this :

(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:04