Class Form

Formulir

Formulir yang berisi properti dan item keseluruhan. Properti meliputi judul, setelan, dan tempat respons disimpan. Item mencakup item pertanyaan seperti kotak centang atau item pilihan, sedangkan item tata letak merujuk pada hal-hal seperti batas halaman. Formulir dapat diakses atau dibuat dari FormApp.

// Open a form by ID and create a new spreadsheet.
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var ss = SpreadsheetApp.create('Spreadsheet Name');

// Update form properties via chaining.
form.setTitle('Form Name')
    .setDescription('Description of form')
    .setConfirmationMessage('Thanks for responding!')
    .setAllowResponseEdits(true)
    .setAcceptingResponses(false);

// Update the form's response destination.
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());

Metode

MetodeJenis hasil yang ditampilkanDeskripsi singkat
addCheckboxGridItem()CheckboxGridItemMenambahkan item pertanyaan baru, yang ditampilkan sebagai petak kolom dan baris, yang memungkinkan responden memilih beberapa pilihan per baris dari serangkaian kotak centang.
addCheckboxItem()CheckboxItemMenambahkan item pertanyaan baru yang memungkinkan responden memilih satu atau beberapa kotak centang, serta kolom "lainnya" opsional.
addDateItem()DateItemMenambahkan item pertanyaan baru yang memungkinkan responden menunjukkan tanggal.
addDateTimeItem()DateTimeItemMenambahkan item pertanyaan baru yang memungkinkan responden menunjukkan tanggal dan waktu.
addDurationItem()DurationItemMenambah item pertanyaan baru yang memungkinkan responden menunjukkan durasi waktu.
addEditor(emailAddress)FormMenambahkan pengguna tertentu ke daftar editor untuk Form.
addEditor(user)FormMenambahkan pengguna tertentu ke daftar editor untuk Form.
addEditors(emailAddresses)FormMenambahkan array pengguna tertentu ke daftar editor untuk Form.
addGridItem()GridItemMenambahkan item pertanyaan baru, yang disajikan sebagai petak kolom dan baris, yang memungkinkan responden memilih satu pilihan per baris dari serangkaian tombol pilihan.
addImageItem()ImageItemMenambahkan item tata letak baru yang menampilkan gambar.
addListItem()ListItemMenambahkan item pertanyaan baru yang memungkinkan responden memilih satu pilihan dari daftar dropdown.
addMultipleChoiceItem()MultipleChoiceItemMenambahkan item pertanyaan baru yang memungkinkan responden memilih satu pilihan dari daftar tombol radio atau kolom "lainnya" opsional.
addPageBreakItem()PageBreakItemMenambahkan item tata letak baru yang menandai awal halaman.
addParagraphTextItem()ParagraphTextItemMenambahkan item pertanyaan baru yang memungkinkan responden memasukkan blok teks.
addScaleItem()ScaleItemMenambahkan item pertanyaan baru yang memungkinkan responden memilih satu opsi dari urutan tombol pilihan bernomor.
addSectionHeaderItem()SectionHeaderItemMenambahkan item tata letak baru yang secara visual menunjukkan awal suatu bagian.
addTextItem()TextItemMenambahkan item pertanyaan baru yang memungkinkan responden memasukkan satu baris teks.
addTimeItem()TimeItemMenambahkan item pertanyaan baru yang memungkinkan responden menunjukkan waktu.
addVideoItem()VideoItemMenambahkan item tata letak baru yang menampilkan video.
canEditResponse()BooleanMenentukan apakah formulir menampilkan link untuk mengedit respons setelah mengirimkannya.
collectsEmail()BooleanMenentukan apakah formulir mengumpulkan alamat email responden.
createResponse()FormResponseMembuat respons baru untuk formulir.
deleteAllResponses()FormMenghapus semua respons yang dikirim dari penyimpanan respons formulir.
deleteItem(index)voidMenghapus item pada indeks tertentu di antara semua item dalam formulir.
deleteItem(item)voidMenghapus item tertentu.
deleteResponse(responseId)FormMenghapus satu respons dari penyimpanan respons formulir.
getConfirmationMessage()StringMendapatkan pesan konfirmasi formulir.
getCustomClosedFormMessage()StringMendapatkan pesan kustom yang ditampilkan jika formulir tidak menerima respons, atau string kosong jika tidak ada pesan kustom yang ditetapkan.
getDescription()StringMendapatkan deskripsi formulir.
getDestinationId()StringMendapatkan ID tujuan respons formulir.
getDestinationType()DestinationTypeMendapatkan jenis tujuan respons formulir.
getEditUrl()StringMendapatkan URL yang dapat digunakan untuk mengakses mode edit formulir.
getEditors()User[]Mendapatkan daftar editor untuk Form ini.
getId()StringMendapatkan ID formulir.
getItemById(id)ItemMendapatkan item dengan ID yang diberikan.
getItems()Item[]Mengambil array dari semua item dalam bentuk.
getItems(itemType)Item[]Mendapatkan array dari semua item dari jenis tertentu.
getPublishedUrl()StringMendapatkan URL yang dapat digunakan untuk merespons formulir.
getResponse(responseId)FormResponseMendapatkan satu respons bentuk berdasarkan ID responsnya.
getResponses()FormResponse[]Mendapatkan array dari semua respons formulir.
getResponses(timestamp)FormResponse[]Mendapatkan array semua respons formulir setelah tanggal dan waktu tertentu.
getShuffleQuestions()BooleanMenentukan apakah urutan pertanyaan pada setiap halaman formulir diacak.
getSummaryUrl()StringMendapatkan URL yang dapat digunakan untuk melihat ringkasan respons formulir.
getTitle()StringMendapatkan judul formulir.
hasLimitOneResponsePerUser()BooleanMenentukan apakah formulir hanya mengizinkan satu respons per responden.
hasProgressBar()BooleanMenentukan apakah formulir menampilkan status progres.
hasRespondAgainLink()BooleanMenentukan apakah formulir menampilkan link untuk mengirimkan respons lain setelah responden menyelesaikan formulir.
isAcceptingResponses()BooleanMenentukan apakah formulir saat ini menerima respons.
isPublishingSummary()BooleanMenentukan apakah formulir menampilkan link untuk melihat ringkasan respons setelah responden menyelesaikan formulir.
isQuiz()BooleanMenentukan apakah formulir merupakan kuis.
moveItem(from, to)ItemMemindahkan item pada indeks tertentu di antara semua item dalam formulir ke indeks tertentu lainnya.
moveItem(item, toIndex)ItemMemindahkan item tertentu ke indeks tertentu di antara semua item dalam formulir.
removeDestination()FormMembatalkan tautan formulir dari tujuan respons saat ini.
removeEditor(emailAddress)FormMenghapus pengguna tertentu dari daftar editor untuk Form.
removeEditor(user)FormMenghapus pengguna tertentu dari daftar editor untuk Form.
requiresLogin()BooleanMenentukan apakah formulir mengharuskan responden login ke akun di domain atau subdomain yang sama sebelum merespons.
setAcceptingResponses(enabled)FormMenetapkan apakah formulir saat ini menerima respons.
setAllowResponseEdits(enabled)FormMenetapkan apakah formulir menampilkan link untuk mengedit respons setelah mengirimkannya.
setCollectEmail(collect)FormMenetapkan apakah formulir mengumpulkan alamat email responden.
setConfirmationMessage(message)FormMenetapkan pesan konfirmasi formulir.
setCustomClosedFormMessage(message)FormMenyetel pesan yang akan ditampilkan jika formulir tidak menerima respons.
setDescription(description)FormMenetapkan deskripsi formulir.
setDestination(type, id)FormMenetapkan tujuan tempat respons formulir disimpan.
setIsQuiz(enabled)FormMenetapkan apakah formulir merupakan kuis.
setLimitOneResponsePerUser(enabled)FormMenetapkan apakah formulir hanya mengizinkan satu respons per responden.
setProgressBar(enabled)FormMenetapkan apakah formulir memiliki status progres.
setPublishingSummary(enabled)FormMenetapkan apakah formulir menampilkan link untuk melihat ringkasan respons setelah responden mengirimkan formulir.
setRequireLogin(requireLogin)FormMenetapkan apakah formulir mengharuskan responden login ke akun di domain atau subdomain yang sama sebelum merespons.
setShowLinkToRespondAgain(enabled)FormMenetapkan apakah formulir menampilkan link untuk mengirimkan respons lain setelah responden melengkapi formulir.
setShuffleQuestions(shuffle)FormMenetapkan apakah urutan pertanyaan di setiap halaman formulir diacak.
setTitle(title)FormMenetapkan judul formulir.
shortenFormUrl(url)StringMengonversi URL panjang untuk formulir menjadi URL singkat.
submitGrades(responses)FormMengirimkan nilai untuk FormResponses yang diberikan.

Dokumentasi mendetail

addCheckboxGridItem()

Menambahkan item pertanyaan baru, yang ditampilkan sebagai petak kolom dan baris, yang memungkinkan responden memilih beberapa pilihan per baris dari serangkaian kotak centang.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a checkbox grid item.
const item = form.addCheckboxGridItem();

// Sets the title 'Where did you celebrate New Year's?'
item.setTitle('Where did you celebrate New Year's?');

// Sets the grid's rows and columns.
item.setRows(['New York', 'San Francisco', 'London'])
  .setColumns(['2014', '2015', '2016', '2017']);

Return

CheckboxGridItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addCheckboxItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memilih satu atau beberapa kotak centang, serta kolom "lainnya" opsional.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a checkbox item.
const item = form.addCheckboxItem();

// Sets the title of the checkbox item to 'Do you prefer cats or dogs?'
item.setTitle('Do you prefer cats or dogs?');

// Sets the choices.
item.setChoiceValues(['Cats', 'Dogs']);

Return

CheckboxItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDateItem()

Menambahkan item pertanyaan baru yang memungkinkan responden menunjukkan tanggal.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a date item.
const item = form.addDateItem();

// Sets the title to 'When were you born?'
item.setTitle('When were you born?');

// Sets the description for the date item.
item.setHelpText('Some helper text.');

Return

DateItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDateTimeItem()

Menambahkan item pertanyaan baru yang memungkinkan responden menunjukkan tanggal dan waktu.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a question with date and time inputs.
const item = form.addDateTimeItem();

// Sets the title to 'When were you born?'
item.setTitle('When were you born?');

// Sets the question as required.
item.setRequired(true);

Return

DateTimeItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addDurationItem()

Menambah item pertanyaan baru yang memungkinkan responden menunjukkan durasi waktu.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a question with a duration input.
const item = form.addDurationItem();

// Sets the title to 'How long can you hold your breath?'
item.setTitle('How long can you hold your breath?');

// Sets the question as required.
item.setRequired(true);

Return

DurationItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditor(emailAddress)

Menambahkan pengguna tertentu ke daftar editor untuk Form. Jika pengguna sudah ada di daftar audiens, metode ini akan mempromosikan pengguna dari daftar pelihat.

Parameter

NamaJenisDeskripsi
emailAddressStringAlamat email pengguna yang akan ditambahkan.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditor(user)

Menambahkan pengguna tertentu ke daftar editor untuk Form. Jika pengguna sudah ada di daftar audiens, metode ini akan mempromosikan pengguna dari daftar pelihat.

Parameter

NamaJenisDeskripsi
userUserRepresentasi pengguna yang akan ditambahkan.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addEditors(emailAddresses)

Menambahkan array pengguna tertentu ke daftar editor untuk Form. Jika salah satu pengguna sudah ada dalam daftar audiens, metode ini akan mempromosikannya dari daftar pelihat.

Parameter

NamaJenisDeskripsi
emailAddressesString[]Array alamat email pengguna yang akan ditambahkan.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addGridItem()

Menambahkan item pertanyaan baru, yang disajikan sebagai petak kolom dan baris, yang memungkinkan responden memilih satu pilihan per baris dari serangkaian tombol pilihan.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a multiple choice grid.
const item = form.addGridItem();

// Sets the title to 'Rate your interests.'
item.setTitle('Rate your interests');

// Sets the grid's rows and columns.
item.setRows(['Cars', 'Computers', 'Celebrities'])
  .setColumns(['Boring', 'So-so', 'Interesting']);

Return

GridItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addImageItem()

Menambahkan item tata letak baru yang menampilkan gambar.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds an image item.
const item = form.addImageItem();

// Gets the Google icon to use as the image.
const img = UrlFetchApp.fetch('https://fonts.gstatic.com/s/i/productlogos/googleg/v6/web-24dp/logo_googleg_color_1x_web_24dp.png');

// Sets the image, title, and description for the item.
item.setTitle('Google icon').setHelpText('Google icon').setImage(img);

Return

ImageItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addListItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memilih satu pilihan dari daftar dropdown.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a dropdown list to the form.
const item = form.addListItem();

// Sets the title to 'Do you prefer cats or dogs?'
item.setTitle('Do you prefer cats or dogs?');

// Sets the description to 'This is description text...'
item.setHelpText('This is description text...');

// Creates and adds choices to the dropdown list.
item.setChoices([
  item.createChoice('dog'),
  item.createChoice('cat')
]);

Return

ListItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addMultipleChoiceItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memilih satu pilihan dari daftar tombol radio atau kolom "lainnya" opsional.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a multiple choice item to the form.
const item = form.addMultipleChoiceItem();

// Sets the title.
item.setTitle('What is your favorite ice cream flavor?');

// Creates some choice items.
const vanilla = item.createChoice('vanilla');
const chocolate = item.createChoice('chocolate');
const strawberry = item.createChoice('strawberry');

// Sets the choices.
item.setChoices([vanilla, chocolate, strawberry]);

Return

MultipleChoiceItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addPageBreakItem()

Menambahkan item tata letak baru yang menandai awal halaman.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds page break items to create a second and third page for the form.
const pageTwo = form.addPageBreakItem();
const pageThree = form.addPageBreakItem();

// Sets the titles for the pages.
pageTwo.setTitle('Page two');
pageThree.setTitle('Page three');

// Upon completion of the first page, sets the form to navigate to the third page.
pageTwo.setGoToPage(pageThree);

// Upon completion of the second page, sets the form to navigate back to the first page.
pageThree.setGoToPage(FormApp.PageNavigationType.RESTART);

Return

PageBreakItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addParagraphTextItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memasukkan blok teks.

// Opens the form by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds the paragraph text item.
const item = form.addParagraphTextItem();

// Sets the title to 'What is your address?'
item.setTitle('What is your address?');

Return

ParagraphTextItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addScaleItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memilih satu opsi dari urutan tombol pilihan bernomor.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds the scale item.
const item = form.addScaleItem();

// Sets the title of the scale item to 'Choose a number.'
item.setTitle('Choose a number');

// Sets the scale to 1-5.
item.setBounds(1, 5);

// Sets the label for the lower and upper bounds.
item.setLabels('Lowest', 'Highest');

Return

ScaleItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addSectionHeaderItem()

Menambahkan item tata letak baru yang secara visual menunjukkan awal suatu bagian.

 // Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds the section heading item.
const item = form.addSectionHeaderItem();

// Sets the title to 'Title of new section.'
item.setTitle('Title of new section');

// Sets the description.
item.setHelpText('Description of new section');

Return

SectionHeaderItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addTextItem()

Menambahkan item pertanyaan baru yang memungkinkan responden memasukkan satu baris teks.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a single-line text item.
const item = form.addTextItem();

// Sets the title to 'What is your name?'
item.setTitle('What is your name?');

Return

TextItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addTimeItem()

Menambahkan item pertanyaan baru yang memungkinkan responden menunjukkan waktu.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a question with a time input.
const item = form.addTimeItem();

// Sets the title to 'What time do you usually wake up in the morning?'
item.setTitle('What time do you usually wake up in the morning?');

Return

TimeItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

addVideoItem()

Menambahkan item tata letak baru yang menampilkan video.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Adds a video item.
const item = form.addVideoItem();

// Sets the title, description, and video.
item.setTitle('YouTube video')
  .setHelpText('Send content automatically via Google Sheets and Apps Script')
  .setVideoUrl('https://youtu.be/xxgQr-jSu9o');

// Sets the alignment to the center.
item.setAlignment(FormApp.Alignment.CENTER);

Return

VideoItem — Item yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

canEditResponse()

Menentukan apakah formulir menampilkan link untuk mengedit respons setelah mengirimkannya.

Terlepas dari setelan ini, metode FormResponse.getEditResponseUrl() memungkinkan penulis skrip yang memiliki akses edit ke formulir untuk membuat URL yang dapat digunakan untuk mengedit respons.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Checks if the form displays a link to edit a response after submitting it.
// The default is false. To let people edit their responses, use
// form.setAllowResponseEdits(true).
const edit = form.canEditResponse();

// If the form doesn't let people edit responses, logs false to the console.
console.log(edit);

Return

Booleantrue jika formulir menampilkan link "Edit respons Anda"; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

collectsEmail()

Menentukan apakah formulir mengumpulkan alamat email responden.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to not collect respondents' email addresses.
form.setCollectEmail(false);

// Checks whether the form collects respondents' email addresses and logs it to the console.
const bool = form.collectsEmail();

console.log(bool);

Return

Booleantrue jika formulir mengumpulkan alamat email; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

createResponse()

Membuat respons baru untuk formulir. Untuk menjawab item pertanyaan, buat ItemResponse dari item, lalu lampirkan ke respons formulir ini dengan memanggil FormResponse.withItemResponse(response). Untuk menyimpan respons yang telah disusun, panggil FormResponse.submit().

Return

FormResponse — Respons formulir yang baru dibuat.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteAllResponses()

Menghapus semua respons yang dikirim dari penyimpanan respons formulir. Metode ini tidak menghapus salinan respons yang disimpan di tujuan respons eksternal (seperti spreadsheet), tetapi menghapus tampilan ringkasan formulir.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteItem(index)

Menghapus item pada indeks tertentu di antara semua item dalam formulir. Menampilkan pengecualian pembuatan skrip jika tidak ada item pada indeks yang diberikan.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets all the items from the form.
const items = form.getItems();

// Finds the index of a paragraph text item and deletes it by the item's index.
const index = items.findIndex(item => item.getType() === FormApp.ItemType.PARAGRAPH_TEXT);
if (index !== -1) {
  form.deleteItem(index);
}

Parameter

NamaJenisDeskripsi
indexIntegerIndeks item di antara semua item dalam formulir.

Menampilkan

Error — jika tidak ada item pada indeks tertentu

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteItem(item)

Menghapus item tertentu. Menampilkan pengecualian pembuatan skrip jika item telah dihapus.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets all of the items from the form.
const items = form.getItems();

// Finds a paragraph text item and deletes it.
const item = items.find(item => item.getType() === FormApp.ItemType.PARAGRAPH_TEXT);
if (item) {
  form.deleteItem(item);
}

Parameter

NamaJenisDeskripsi
itemItemItem yang akan dihapus.

Menampilkan

Error — jika item tidak ada dalam formulir

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

deleteResponse(responseId)

Menghapus satu respons dari penyimpanan respons formulir. Metode ini tidak menghapus salinan respons yang disimpan di tujuan respons eksternal (seperti spreadsheet), tetapi menghapus respons dari tampilan ringkasan formulir. ID respons dapat diambil dengan FormResponse.getId().

Parameter

NamaJenisDeskripsi
responseIdStringID respons formulir yang akan dihapus.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getConfirmationMessage()

Mendapatkan pesan konfirmasi formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the confirmation message to display after someone submits the form.
form.setConfirmationMessage('You successfully submitted the form.');

// Gets the confirmation message and logs it to the console.
const message = form.getConfirmationMessage();

console.log(message);

Return

String — Pesan konfirmasi formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getCustomClosedFormMessage()

Mendapatkan pesan kustom yang ditampilkan jika formulir tidak menerima respons, atau string kosong jika tidak ada pesan kustom yang ditetapkan.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets a custom closed form message to display to the user when the form
// no longer accepts responses.
form.setCustomClosedFormMessage('The form is no longer accepting responses.');

// Gets the custom message set for the form and logs it to the console.
const message = form.getCustomClosedFormMessage();

console.log(message);

Return

String — Pesan kustom yang akan ditampilkan jika formulir tidak menerima respons, atau string kosong jika tidak ada pesan kustom yang ditetapkan.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDescription()

Mendapatkan deskripsi formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form description.
form.setDescription('This is the form description.');

// Gets the form description and logs it to the console.
const description = form.getDescription();

console.log(description);

Return

String — Deskripsi formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDestinationId()

Mendapatkan ID tujuan respons formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Creates a spreadsheet to use as the response destination.
const ss = SpreadsheetApp.create('Test_Spreadsheet');

// Updates the form's response destination.
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());

// Gets the ID of the form's response destination and logs it to the console.
const destinationId = form.getDestinationId();

console.log(destinationId);

Return

String — ID tujuan respons formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getDestinationType()

Mendapatkan jenis tujuan respons formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc1234556/edit');

// Gets the type of the form's response destination and logs it to the console.
const destinationType = form.getDestinationType().name();

console.log(destinationType);

Return

DestinationType — Jenis tujuan respons formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getEditUrl()

Mendapatkan URL yang dapat digunakan untuk mengakses mode edit formulir.

// Opens the form by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the URL that accesses the form's edit mode and logs it to the console.
const url = form.getEditUrl();

console.log(url);

Return

String — URL untuk mengedit formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getEditors()

Mendapatkan daftar editor untuk Form ini.

Return

User[] — Array pengguna dengan izin edit.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getId()

Mendapatkan ID formulir.

// Opens the form by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the ID of the form and logs it to the console.
const id = form.getId();

console.log(id);

Return

String — ID formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItemById(id)

Mendapatkan item dengan ID yang diberikan. Menampilkan null jika ID tidak sesuai dengan item dalam formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the ID of the first item on the form.
const itemId = form.getItems()[0].getId();

// Gets the item from the ID.
const item = form.getItemById(itemId);

// Gets the name of the item type and logs it to the console.
const type = item.getType().name();

console.log(type);

Parameter

NamaJenisDeskripsi
idIntegerID item.

Return

Item — Item dengan ID yang diberikan, atau null jika item tidak ada dalam formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItems()

Mengambil array dari semua item dalam bentuk.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the list of items in the form.
const items = form.getItems();

// Gets the type for each item and logs them to the console.
const types = items.map((item) => item.getType().name());

console.log(types);

Return

Item[] — Array dari semua item dalam formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getItems(itemType)

Mendapatkan array dari semua item dari jenis tertentu.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets a list of all checkbox items on the form.
const items = form.getItems(FormApp.ItemType.CHECKBOX);

// Gets the title of each checkbox item and logs them to the console.
const checkboxItemsTitle = items.map((item) => item.asCheckboxItem().getTitle());
console.log(checkboxItemsTitle);

Parameter

NamaJenisDeskripsi
itemTypeItemTypeJenis item yang akan diambil.

Return

Item[] — Array dari semua item dengan jenis tersebut.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getPublishedUrl()

Mendapatkan URL yang dapat digunakan untuk merespons formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the URL to respond to the form and logs it to the console.
const url = form.getPublishedUrl();
console.log(url);

Return

String — URL untuk merespons formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponse(responseId)

Mendapatkan satu respons bentuk berdasarkan ID responsnya. ID respons dapat diambil dari FormResponse.getId().

Parameter

NamaJenisDeskripsi
responseIdStringID untuk respons formulir.

Return

FormResponse — Respons formulir.

Menampilkan

Error — jika respons tidak ada

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponses()

Mendapatkan array dari semua respons formulir.

Return

FormResponse[] — Array dari semua respons formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getResponses(timestamp)

Mendapatkan array semua respons formulir setelah tanggal dan waktu tertentu.

Parameter

NamaJenisDeskripsi
timestampDateTanggal dan waktu paling awal untuk respons formulir yang harus ditampilkan.

Return

FormResponse[] — Daftar respons formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getShuffleQuestions()

Menentukan apakah urutan pertanyaan pada setiap halaman formulir diacak.

Return

Booleantrue jika urutan pertanyaan di setiap halaman formulir diacak; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getSummaryUrl()

Mendapatkan URL yang dapat digunakan untuk melihat ringkasan respons formulir. Kecuali setPublishingSummary(enabled) ditetapkan ke true, hanya pengguna dengan izin edit ke formulir yang dapat mengakses URL.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// Opens the form by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the URL to view a summary of the form's responses and logs it to the console.
const url = form.getSummaryUrl();
console.log(url);

Return

String — URL untuk melihat ringkasan respons.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getTitle()

Mendapatkan judul formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the title of the form to 'For_Testing.'
form.setTitle('For_Testing');

// Gets the title of the form and logs it to the console.
const title = form.getTitle();
console.log(title);

Return

String — Judul formulir.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

hasLimitOneResponsePerUser()

Menentukan apakah formulir hanya mengizinkan satu respons per responden. Jika nilainya true, skrip tidak dapat mengirimkan respons formulir sama sekali.

Return

Booleantrue jika formulir hanya mengizinkan satu respons per responden; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

hasProgressBar()

Menentukan apakah formulir menampilkan status progres.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// Opens the form by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Displays the progress bar on the form.
form.setProgressBar(true);

// Checks if the form displays a progress bar and logs it to the console.
console.log(form.hasProgressBar());

Return

Booleantrue jika formulir menampilkan status progres; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

Menentukan apakah formulir menampilkan link untuk mengirimkan respons lain setelah responden menyelesaikan formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to display a link to submit another
// response after someone submits the form.
form.setShowLinkToRespondAgain(true);

// Checks if the form displays a 'Submit another response' link and logs it to the console.
console.log(form.hasRespondAgainLink());

Return

Booleantrue jika formulir menampilkan link "Kirim respons lain"; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isAcceptingResponses()

Menentukan apakah formulir saat ini menerima respons.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to accept responses.
form.setAcceptingResponses(true);

// Checks if the form is accepting responses or not and logs it to the console.
const accepting = form.isAcceptingResponses();
console.log(accepting);

Return

Booleantrue jika formulir menerima respons; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isPublishingSummary()

Menentukan apakah formulir menampilkan link untuk melihat ringkasan respons setelah responden menyelesaikan formulir.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to display a link to a summary of
// the responses after someone submits the form.
form.setPublishingSummary(true);

// Checks if the form displays a "See previous responses" link and logs it to the console.
const publishingLink = form.isPublishingSummary();
console.log(publishingLink);

Return

Booleantrue jika formulir menampilkan link "Lihat respons sebelumnya"; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isQuiz()

Menentukan apakah formulir merupakan kuis.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form as a quiz.
form.setIsQuiz(true);

// Checks if the form is a quiz or not and logs it to the console.
console.log(form.isQuiz());

Return

Booleantrue jika formulir menerima respons; false jika tidak.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

moveItem(from, to)

Memindahkan item pada indeks tertentu di antara semua item dalam formulir ke indeks tertentu lainnya. Menampilkan pengecualian pembuatan skrip jika indeks to di luar batas.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Moves the first item to be the last item.
form.moveItem(0, form.getItems().length - 1);

Parameter

NamaJenisDeskripsi
fromIntegerIndeks item saat ini di antara semua item dalam formulir.
toIntegerIndeks baru untuk item di antara semua item dalam formulir.

Return

Item — Item yang dipindahkan.

Menampilkan

Error — jika salah satu indeks di luar batas.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

moveItem(item, toIndex)

Memindahkan item tertentu ke indeks tertentu di antara semua item dalam formulir. Menampilkan pengecualian skrip jika indeks yang diberikan berada di luar batas.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the first item.
const item = form.getItems()[0];

// Moves the item to be the last item.
form.moveItem(item, form.getItems().length - 1);

Parameter

NamaJenisDeskripsi
itemItemItem yang akan dipindahkan.
toIndexIntegerIndeks baru untuk item di antara semua item dalam formulir.

Return

Item — Item yang dipindahkan.

Menampilkan

Error — jika indeks di luar batas.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeDestination()

Membatalkan tautan formulir dari tujuan respons saat ini. Tujuan sebelumnya yang tidak tertaut masih mempertahankan salinan semua respons sebelumnya. Semua formulir, termasuk yang tidak memiliki tujuan yang ditetapkan secara eksplisit, menyimpan salinan respons di penyimpanan respons formulir. Jika formulir saat ini tidak memiliki tujuan respons, metode ini tidak akan berpengaruh.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Opens a spreadsheet to use for the response destination.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Updates the form's response destination to the spreadsheet.
form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());

// Unlinks the form from the spreadsheet.
form.removeDestination();

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeEditor(emailAddress)

Menghapus pengguna tertentu dari daftar editor untuk Form. Metode ini tidak memblokir pengguna agar tidak mengakses Form jika mereka termasuk dalam class pengguna yang memiliki akses umum—misalnya, jika Form dibagikan ke seluruh domain pengguna, atau jika Form berada di drive bersama yang dapat diakses pengguna.

Untuk file Drive, tindakan ini juga akan menghapus pengguna dari daftar pelihat.

Parameter

NamaJenisDeskripsi
emailAddressStringAlamat email pengguna yang akan dihapus.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

removeEditor(user)

Menghapus pengguna tertentu dari daftar editor untuk Form. Metode ini tidak memblokir pengguna agar tidak mengakses Form jika mereka termasuk dalam class pengguna yang memiliki akses umum—misalnya, jika Form dibagikan ke seluruh domain pengguna, atau jika Form berada di drive bersama yang dapat diakses pengguna.

Untuk file Drive, tindakan ini juga akan menghapus pengguna dari daftar pelihat.

Parameter

NamaJenisDeskripsi
userUserRepresentasi pengguna yang akan dihapus.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

requiresLogin()

Menentukan apakah formulir mengharuskan responden login ke akun di domain atau subdomain yang sama sebelum merespons.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Checks if the form requires respondents to log in to a Google Workspace account
// before responding and logs it to the console.
const login = form.requiresLogin();
console.log(login);

Return

Booleantrue jika formulir mengharuskan pengguna untuk login; false jika tidak.


setAcceptingResponses(enabled)

Menetapkan apakah formulir saat ini menerima respons. Default untuk formulir baru adalah true.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to accept responses.
form.setAcceptingResponses(true);

// Checks whether the form is accepting responses or not and logs it to the console.
console.log(form.isAcceptingResponses());

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir harus menerima respons; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setAllowResponseEdits(enabled)

Menetapkan apakah formulir menampilkan link untuk mengedit respons setelah mengirimkannya. Default untuk formulir baru adalah false.

Terlepas dari setelan ini, metode FormResponse.getEditResponseUrl() memungkinkan penulis skrip yang memiliki izin edit pada formulir untuk menghasilkan URL yang dapat digunakan untuk mengedit respons.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Shows "Edit your response" link after someone submits the form.
form.setAllowResponseEdits(true);

// Checks whether the option to edit the form after a user submits it is set to true or not
// and logs it to the console.
console.log(form.canEditResponse());

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir menampilkan link "Edit respons Anda"; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setCollectEmail(collect)

Menetapkan apakah formulir mengumpulkan alamat email responden. Default untuk formulir baru adalah false.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to collect respondents' email addresses.
form.setCollectEmail(true);

// Checks whether the value is set to true or false and logs it to the console.
const collect = form.collectsEmail();
console.log(collect);

Parameter

NamaJenisDeskripsi
collectBooleantrue jika formulir harus mengumpulkan alamat email; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setConfirmationMessage(message)

Menetapkan pesan konfirmasi formulir.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets a custom confirmation message to display after someone submits the form.
form.setConfirmationMessage('Your form has been successfully submitted.');

// Gets the confirmation message set for the form and logs it to the console.
const message = form.getConfirmationMessage();
console.log(message);

Parameter

NamaJenisDeskripsi
messageStringPesan konfirmasi baru di formulir.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setCustomClosedFormMessage(message)

Menyetel pesan yang akan ditampilkan jika formulir tidak menerima respons. Jika tidak ada pesan yang ditetapkan, formulir akan menggunakan pesan default.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form to not accept responses.
form.setAcceptingResponses(false);

// Sets a custom closed form message to display to the user.
form.setCustomClosedFormMessage('The form is no longer accepting responses.');

// Gets the custom message set for the form and logs it to the console.
const message = form.getCustomClosedFormMessage();
console.log(message);

Parameter

NamaJenisDeskripsi
messageStringPesan yang akan ditampilkan jika formulir tidak menerima respons.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setDescription(description)

Menetapkan deskripsi formulir.

Parameter

NamaJenisDeskripsi
descriptionStringDeskripsi baru formulir.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setDestination(type, id)

Menetapkan tujuan tempat respons formulir disimpan. Semua formulir, termasuk yang tidak memiliki tujuan yang ditetapkan secara eksplisit, menyimpan salinan respons di penyimpanan respons formulir.

Parameter

NamaJenisDeskripsi
typeDestinationTypeJenis tujuan respons formulir.
idStringID tujuan respons formulir.

Return

FormForm ini, untuk perantaian.

Menampilkan

Error — jika ID tujuan yang diberikan tidak valid

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setIsQuiz(enabled)

Menetapkan apakah formulir merupakan kuis. Default untuk formulir baru adalah false.

Pertanyaan yang sudah diberi nilai hanya diizinkan di Kuis, jadi menyetelnya ke false akan menyebabkan semua opsi penilaian dihapus dari semua pertanyaan.

Setelan kuis hanya tersedia di UI Formulir yang baru; membuat Kuis akan memilih formulir untuk menggunakan UI baru.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Makes the form a quiz.
form.setIsQuiz(true);

// Checks whether the form is a quiz or not and logs it to the console.
console.log(form.isQuiz());

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika fitur kuis harus diaktifkan untuk formulir; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setLimitOneResponsePerUser(enabled)

Menetapkan apakah formulir hanya mengizinkan satu respons per responden. Default untuk formulir baru adalah false. Jika nilai ditetapkan ke true, skrip tidak dapat mengirim respons formulir sama sekali.

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir hanya mengizinkan satu respons per responden; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setProgressBar(enabled)

Menetapkan apakah formulir memiliki status progres. Default untuk formulir baru adalah false.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Displays the progress bar on the form.
form.setProgressBar(true);

// Checks whether the form has a progress bar and logs it to the console.
console.log(form.hasProgressBar());

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir menampilkan status progres; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setPublishingSummary(enabled)

Menetapkan apakah formulir menampilkan link untuk melihat ringkasan respons setelah responden mengirimkan formulir. Default untuk formulir baru adalah false.

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir harus menampilkan link "Lihat respons sebelumnya"; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setRequireLogin(requireLogin)

Menetapkan apakah formulir mengharuskan responden login ke akun di domain atau subdomain yang sama sebelum merespons. Default untuk formulir baru adalah false kecuali jika administrator domain mengubah setelan default.

Fitur ini hanya tersedia untuk formulir yang dibuat oleh pengguna Google Workspace. Pengguna jenis akun Google lainnya tidak dapat diwajibkan untuk login.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Sets the form so that users must log in to their Google Workspace account.
form.setRequireLogin(true);

// Checks whether the form requires login or not and logs it to the console.
console.log(form.requiresLogin());

Parameter

NamaJenisDeskripsi
requireLoginBooleantrue jika formulir mengharuskan pengguna untuk login; false jika tidak.

Return

Form — Bentuk saat ini (untuk perantaian).

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setShowLinkToRespondAgain(enabled)

Menetapkan apakah formulir menampilkan link untuk mengirimkan respons lain setelah responden melengkapi formulir. Default untuk formulir baru adalah true.

Parameter

NamaJenisDeskripsi
enabledBooleantrue jika formulir menampilkan link "Kirim respons lain"; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setShuffleQuestions(shuffle)

Menetapkan apakah urutan pertanyaan di setiap halaman formulir diacak.

Parameter

NamaJenisDeskripsi
shuffleBooleantrue jika urutan pertanyaan di setiap halaman formulir harus diacak; false jika tidak.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setTitle(title)

Menetapkan judul formulir.

Parameter

NamaJenisDeskripsi
titleStringJudul baru formulir.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

shortenFormUrl(url)

Mengonversi URL panjang untuk formulir menjadi URL singkat. Menampilkan pengecualian jika URL panjang bukan milik Google Formulir.

Parameter

NamaJenisDeskripsi
urlStringURL yang akan dipersingkat.

Return

String — URL dalam bentuk http://goo.gl/forms/1234.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

submitGrades(responses)

Mengirimkan nilai untuk FormResponses yang diberikan.

Jika kode Anda menyertakan pemicu onFormSubmit, memanggil submitGrades() akan memicu kondisi onFormSubmit dan menyebabkan loop tanpa henti. Untuk mencegah loop tanpa henti, tambahkan kode yang memeriksa apakah nilai sudah ada sebelum memanggil submitGrades().

Parameter

NamaJenisDeskripsi
responsesFormResponse[]Array dari semua respons formulir.

Return

FormForm ini, untuk perantaian.

Otorisasi

Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms