LoginSignup
1
3

More than 5 years have passed since last update.

GoogleAppsScriptを使ってgoogleフォームの記入に期限を付ける

Posted at

function endFormCheck() {

  var today = new Date();
  var firstday =  new Date(today.getFullYear(), today.getMonth(), 1);//1日を取得
  var fiveday =  new Date(today.getFullYear(), today.getMonth(), 5);//5日を取得

  var today = Utilities.formatDate(today, "Asia/Tokyo", "yyyy-MM-dd");
  var firstday = Utilities.formatDate(firstday, "Asia/Tokyo", "yyyy-MM-dd");
  var fiveday = Utilities.formatDate(fiveday, "Asia/Tokyo", "yyyy-MM-dd");
  var form = FormApp.getActiveForm();
  //var LIMIT_COUNT = 3; //ここでカウント上限を設定

  Logger.log(today);
  Logger.log(firstday);
  Logger.log(fiveday);

  //if (form.getResponses().length >= LIMIT_COUNT) {

  if (today >= firstday && today <= fiveday) {
    form.setAcceptingResponses(true);
    Logger.log("期間内");
  }else{
    form.setAcceptingResponses(false);
    Logger.log("期間外");
    //上記は、http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11115562281を参考に作成
  }

}
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3