我正在尝试使用触发器onFormResponse来运行该函数。但是,当我使用实时表单进行测试时,没有任何反应。我尝试删除,重新创建触发器和脚本,但它仍然无法正常工作。谢谢你的帮助!
function onSubmit(e) {
//function get ID of the submitted response, log it to the console
//run a afunction that ask for permission to get a refilled URL
//based on the submitted one
//email the log to me
//get current form
var currentForm = FormApp.getActiveForm();
// Get ID of form on submited
var ID = e.response.getId();
Logger.log(ID);
checkPermission(currentResponse);
var recipient = Session.getActiveUser().getEmail();
var subject = 'Log';
var body = Logger.getLog();
MailApp.sendEmail(recipient, subject, body);
Logger.clear();
}
function checkPermission(e){
var ui = FormApp.getUi();
var dialogBox = ui.alert('Do you want to create a prefill form?',
FormApp.getUi().ButtonSet.YES_NO);
if(dialogBox == ui.Botton.YES){
var link = ui.alert(e.toPrefilledUrl());
}
}
function triggerTester(){
// create a an on form submit trigger for function onSubmit
var currentForm = FormApp.getActiveForm();
ScriptApp.newTrigger('onSubmit')
.forForm(currentForm)
.onFormSubmit().create();
}
答案 0 :(得分:1)
我试着发表评论,但不幸的是我没有足够的声誉:
我会使用这个解决方案:
function onSubmitTrigger(){
//psuedocode(ish)
/*
1.Get range of values
2.Find last submitted value
3.Pass value to function "onSubmit"
*/
}
function onSubmit(e) {
//function get ID of the submitted response, log it to the console
//run a afunction that ask for permission to get a refilled URL
//based on the submitted one
//email the log to me
//get current form
var currentForm = FormApp.getActiveForm();
// Get ID of form on submited
var ID = e.response.getId();
Logger.log(ID);
checkPermission(currentResponse);
var recipient = Session.getActiveUser().getEmail();
var subject = 'Log';
var body = Logger.getLog();
MailApp.sendEmail(recipient, subject, body);
Logger.clear();
}
function checkPermission(e){
var ui = FormApp.getUi();
var dialogBox = ui.alert('Do you want to create a prefill form?',
FormApp.getUi().ButtonSet.YES_NO);
if(dialogBox == ui.Botton.YES){
var link = ui.alert(e.toPrefilledUrl());
}
}
function triggerTester(){
// create a an on form submit trigger for function onSubmit
var currentForm = FormApp.getActiveForm();
ScriptApp.newTrigger('onSubmit')
.forForm(currentForm)
.onFormSubmit().create();
}
答案 1 :(得分:0)
问题是Ui函数不能应用于表单响应,而只能应用于编辑器,而我正在尝试添加“弹出”对话框来检查权限。目前,还没有为Google表单响应创建弹出对话框的工作。