whiteknight07Avatar border
TS
whiteknight07
Tanya soal script google form
Siang gan.
Ane lagi mau bikin google form yang berbatas waktu dan jumlah pengguna
Setelah ane googling ketemulah web ini: https://www.labnol.org/internet/sche...e-forms/20707/

Ane coba ikutin caranya, masukin script di Script Editor
Nah pas di langkah activating, ada error message, katanya gini: TypeError: Cannot call method "setAcceptingResponses" of null. (line 61)

Ini ane copas in script nya:

Code:
FORM_OPEN_DATE = "2014-12-20 08:00";
FORM_CLOSE_DATE = "2014-12-25 23:30";
RESPONSE_COUNT = "100";

/* Web tutorial: http://labnol.org/?p=20707 */

/* Initialize the form, setup time based triggers */
function Initialize() {

deleteTriggers_();

if ((FORM_OPEN_DATE !== "") &&
((new Date()).getTime() < parseDate_(FORM_OPEN_DATE).getTime())) {
closeForm();
ScriptApp.newTrigger("openForm")
.timeBased()
.at(parseDate_(FORM_OPEN_DATE))
.create();
}

if (FORM_CLOSE_DATE !== "") {
ScriptApp.newTrigger("closeForm")
.timeBased()
.at(parseDate_(FORM_CLOSE_DATE))
.create();
}

if (RESPONSE_COUNT !== "") {
ScriptApp.newTrigger("checkLimit")
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}

}

/* Delete all existing Script Triggers */
function deleteTriggers_() {
var triggers = ScriptApp.getProjectTriggers();
for (var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
}

/* Send a mail to the form owner when the form status changes */
function informUser_(subject) {
var formURL = FormApp.getActiveForm().getPublishedUrl();
MailApp.sendEmail(Session.getActiveUser().getEmail(), subject, formURL);
}

/* Allow Google Form to Accept Responses */
function openForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(true);
informUser_("Your Google Form is now accepting responses");
}

/* Close the Google Form, Stop Accepting Reponses */
function closeForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
deleteTriggers_();
informUser_("Your Google Form is no longer accepting responses");
}

/* If Total # of Form Responses >= Limit, Close Form */
function checkLimit() {
if (FormApp.getActiveForm().getResponses().length >= RESPONSE_COUNT ) {
closeForm();
}
}

/* Parse the Date for creating Time-Based Triggers */
function parseDate_(d) {
return new Date(d.substr(0,4), d.substr(5,2)-1,
d.substr(8,2), d.substr(11,2), d.substr(14,2));
}

/* Written by Amit Agarwal [email]amit@labnol.org[/email] */



Itu yg ane bold yg Line 61 nya gan

Ada yang tau gimana cara benerinnya? emoticon-Bingungemoticon-Bingung
0
1.5K
1
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Mari bergabung, dapatkan informasi dan teman baru!
Templates & Scripts Stuff
Templates & Scripts Stuff
icon
2.5KThread655Anggota
Terlama
GuestAvatar border
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Ikuti KASKUS di
© 2023 KASKUS, PT Darta Media Indonesia. All rights reserved.