Google Apps脚本格式:e.namedValues不记录任何内容 [英] Google Apps Script Form: e.namedValues logs nothing

查看:70
本文介绍了Google Apps脚本格式:e.namedValues不记录任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本的Google Apps表单,其中有两个问题,资源(带有两个选项的单选按钮)和名称(文本字段).我想在提交时选择表单值,所以我设置了一个触发器(在表单提交时)来调用函数:

I have a very basic Google Apps form with two questions, Resource (radio button with two options) and Name (Text Field). I'd like to pick the form values upon submission so I've set up a trigger (on form submit) to call a function:

function onFormSubmit(e) {
  Logger.log(e.namedValues["Resource"]);
}

知道我在做什么错吗?

推荐答案

我想出了实现此目的的方法,下面是代码:

I figured the way to achieve this, here's the code:

function onFormSubmit(e) {
  var frm = FormApp.getActiveForm().getItems();
  var rsc = e.response.getResponseForItem(frm[0]).getResponse();
  var reasonSubmitted = e.response.getResponseForItem(frm[1]).getResponse();
  var dateRequested = e.response.getResponseForItem(frm[2]).getResponse();

   var submitter = Session.getActiveUser().getEmail();

  //Logger.log(e.response);
  Logger.log("resource: " + rsc
  + " reason: " + "resource: " + reasonSubmitted);
  }

这将使您可以访问每个问题的单个答案

This will give you access to the individual responses for each question

这篇关于Google Apps脚本格式:e.namedValues不记录任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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