我有一个Google表单,我希望每天在该表单上将响应限制为一定的时间范围。我只想接受每周7天在0800到2000之间的回复。我使用了先前回答此问题的代码,因为我的表单仍然不响应。我已经附上了脚本的副本和指向表单的链接。
function initTrigger(){
ScriptApp.newTrigger("Timer").timeBased().atHour(0).everyDays(1).create();
}
function Timer() {
ScriptApp.getProjectTriggers().forEach(function(e){
if(e.getHandlerFunction() == "openForm" || e.getHandlerFunction() == "closeForm") {
ScriptApp.deleteTrigger(e)
}
});
var time = new Date()
time.setHours(8);
time.setMinutes(0);
ScriptApp.newTrigger("openForm").timeBased().at(time).create();
time.setHours(20);
time.setMinutes(0);
ScriptApp.newTrigger("closeForm").timeBased().at(time).create();
}
function openForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(true);
}
function closeForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
//deleteTriggers_();
}