iT邦幫忙

0

google 表單的腳本無法運作

  • 分享至 

  • xImage
//限制 Google 表單的填寫人電子信箱不能重複,以及限制表單的最大填寫人數:
function onSubmit(e) {
  var form = FormApp.getActiveForm();
  var responses = form.getResponses();
  var emailList = [];
  
  for (var i = 0; i < responses.length; i++) {
    var response = responses[i];
    var itemResponses = response.getItemResponses();
    
    for (var j = 0; j < itemResponses.length; j++) {
      var itemResponse = itemResponses[j];
      
      // If email address question, check for uniqueness
      if (itemResponse.getItem().getTitle() === "Email Address") {
        if (emailList.indexOf(itemResponse.getResponse()) !== -1) {
          form.setAcceptingResponses(false);
          throw new Error("This email has already been used to submit the form.");
        }
        emailList.push(itemResponse.getResponse());
      }
    }
  }
  
  // If max response limit is reached
  if (responses.length >= 100) {  // change 100 to desired max responses
    form.setAcceptingResponses(false);
    throw new Error("This form has reached its maximum response limit.");
  }
}

這是向AI訊問後,給的建議代碼,啟動觸發執行後,填寫新表單後,限制次數會執行,電子信箱就完全沒有反應,請問是否有語法的錯誤或者應該要在怎樣調整,盼有人可以指點,謝謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答