问题描述
我有一个Google表单,当由绑定到该表单链接到的电子表格的应用程序中的onSubmit
事件触发时,它会做一些事情。触发onSubmit
时,在执行控制台的日志中看到,提交事件对象的namedValues
段中有一个空白键。例如。表单的已提交事件对象看起来像...
{"authMode":"FULL","namedValues":{"Expected field 1":["Expected Value 1"],"Expected field 2":["Expected Value 2"],"":["","",""],"Expected field 3":["Expected Value 3"],},"range":{"columnEnd":6,"columnStart":1,"rowEnd":4,"rowStart":4},"source":{},"triggerUid":"xxxxxx","values":["Expected Value 1","Expected Value 2","Expected Value 3",""]}
我正在使用的应用程序代码如下...
let EXPECTED_SUBMIT_VALUES = [
"Timestamp","Email Address","Project Name","Description","Expected End Date","User UUID"
]
function isTrigger(funcName){
let r=false;
if(funcName){
let allTriggers=ScriptApp.getProjectTriggers();
for (let i=0;i<allTriggers.length;i++){
if(funcName==allTriggers[i].getHandlerFunction()){
r=true;
break;
}
}
}
return r;
}
function onFormSubmit(e) {
// logging submission values
if(!e) {
sendErrorEmail("No submit response detected")
}
// do some stuff
// get form response
let SUBMISSION = e.namedValues
Logger.log("Submission namedValues = " + JSON.stringify(SUBMISSION))
Logger.log(typeof SUBMISSION)
// do input validation
//...check that all the namedValues are in the EXPECTED_SUBMIT_VALUES list
//...some other stuff
}
// link to form responsee onsubmit evevnt
let ss = SpreadsheetApp.getActive();
let triggers = ScriptApp.getProjectTriggers()
Logger.log(triggers)
if(!isTrigger('onFormSubmit')) {
ScriptApp.newTrigger('onFormSubmit').forSpreadsheet(ss).onFormSubmit().create();
}
此应用程序绑定到的我的Google表单响应电子表格包含该脚本的EXPECTED_SUBMIT_VALUES列表中的所有字段。
任何有更多经验的人都知道如何摆脱这个""
namedValue
?为什么甚至在这里也是如此(我怀疑这与我一直在手动移动和删除表单链接的电子表格中的列,但实际上是IDk有关)的事实?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)