Class Form

Formularz

Formularz zawierający ogólne właściwości i elementy. Właściwości to tytuł, ustawienia i miejsce przechowywania odpowiedzi. Elementy pytania obejmują m.in. pola wyboru i elementy radiowe, a elementy układu dotyczą np. podziałów stron. Formularze można otwierać i tworzyć na stronie 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());

Metody

MetodaZwracany typKrótki opis
addCheckboxGridItem()CheckboxGridItemDodaje nowy element pytania w formie siatki i wierszy, które pozwalają ankietowanym wybrać kilka opcji w danym wierszu z sekwencji pól wyboru.
addCheckboxItem()CheckboxItemDodaje nowy element pytania, który pozwala respondentowi wybrać co najmniej jedno pole wyboru, a także opcjonalne pole „inne”.
addDateItem()DateItemDodaje nowy element pytania, który umożliwia respondentowi określenie daty.
addDateTimeItem()DateTimeItemDodaje nowy element pytania, który umożliwia respondentowi określenie daty i godziny.
addDurationItem()DurationItemDodaje nowy element pytania, który umożliwia respondentowi wskazanie czasu trwania.
addEditor(emailAddress)FormDodaje danego użytkownika do listy edytorów elementu Form.
addEditor(user)FormDodaje danego użytkownika do listy edytorów elementu Form.
addEditors(emailAddresses)FormDodaje podaną tablicę użytkowników do listy edytorów obiektu Form.
addGridItem()GridItemDodaje nowy element pytania w formie siatki kolumn i wierszy, umożliwiając respondentowi wybranie jednej odpowiedzi w wierszu.
addImageItem()ImageItemDołącza nowy element układu, który wyświetla obraz.
addListItem()ListItemDodaje nowy element pytania, który umożliwia respondentowi wybór jednego z listy.
addMultipleChoiceItem()MultipleChoiceItemDodaje nowy element pytania, który umożliwia respondentowi wybranie jednego z przycisku lub opcjonalnego pola „inne”.
addPageBreakItem()PageBreakItemDodaje nowy element układu, który wyznacza początek strony.
addParagraphTextItem()ParagraphTextItemDodaje nowy element pytania, który umożliwia respondentowi wpisanie bloku tekstu.
addScaleItem()ScaleItemDołącza nowy element pytania, który pozwala respondentowi wybrać jedną z następujących po sobie przycisków opcji.
addSectionHeaderItem()SectionHeaderItemZawiera nowy element układu, który wskazuje początek sekcji.
addTextItem()TextItemDodaje nowy element pytania, który pozwala respondentowi wpisać jeden wiersz tekstu.
addTimeItem()TimeItemDodaje nowy element pytania, który pozwala ankietowanym określić godzinę.
addVideoItem()VideoItemDołącza nowy element układu, który wyświetla film.
canEditResponse()BooleanOkreśla, czy po przesłaniu formularza w formularzu ma być edytowany link.
collectsEmail()BooleanOkreśla, czy formularz zbiera adresy e-mail użytkowników.
createResponse()FormResponseTworzy nową odpowiedź na formularz.
deleteAllResponses()Formspowoduje usunięcie wszystkich przesłanych odpowiedzi z magazynu odpowiedzi.
deleteItem(index)voidUsuwa element o danym indeksie ze wszystkich elementów w formularzu.
deleteItem(item)voidUsuwa dany element.
deleteResponse(responseId)FormUsuwa pojedynczą odpowiedź z magazynu odpowiedzi z formularza.
getConfirmationMessage()StringPobiera wiadomość z potwierdzeniem formularza.
getCustomClosedFormMessage()StringPobiera komunikat niestandardowy wyświetlany, jeśli formularz nie przyjmuje odpowiedzi, lub pusty ciąg, jeśli nie jest ustawiona żadna wiadomość niestandardowa.
getDescription()StringPobiera opis formularza.
getDestinationId()StringPobiera identyfikator miejsca docelowego odpowiedzi z formularza.
getDestinationType()DestinationTypePobiera typ miejsca docelowego odpowiedzi na formularz.
getEditUrl()StringPobiera adres URL, który może służyć do uzyskiwania dostępu do trybu edycji formularza.
getEditors()User[]Pobiera listę edytorów na koncie Form.
getId()StringPobiera identyfikator formularza.
getItemById(id)ItemPobiera element o podanym identyfikatorze.
getItems()Item[]Pobiera tablicę ze wszystkimi elementami w formularzu.
getItems(itemType)Item[]Pobiera tablicę ze wszystkimi elementami danego typu.
getPublishedUrl()StringPobiera adres URL, którego można użyć do odpowiedzi na formularz.
getResponse(responseId)FormResponsePobiera odpowiedź z 1 formularza na podstawie jej identyfikatora.
getResponses()FormResponse[]Pobiera tablicę ze wszystkimi odpowiedziami z formularza.
getResponses(timestamp)FormResponse[]Pobiera tablicę ze wszystkimi odpowiedziami z danego formularza po określonej dacie i godzinie.
getShuffleQuestions()BooleanOkreśla kolejność pytań na każdej stronie formularza.
getSummaryUrl()StringPobiera adres URL, którego można używać do wyświetlania podsumowania odpowiedzi z formularza.
getTitle()StringPobiera tytuł formularza.
hasLimitOneResponsePerUser()BooleanOkreśla, czy w formularzu można odpowiedzieć tylko raz na użytkownika.
hasProgressBar()BooleanOkreśla, czy formularz ma wyświetlać pasek postępu.
hasRespondAgainLink()BooleanOkreśla, czy w formularzu wyświetla się link do przesyłania kolejnej odpowiedzi.
isAcceptingResponses()BooleanOkreśla, czy formularz przyjmuje obecnie odpowiedzi.
isPublishingSummary()BooleanOkreśla, czy w formularzu jest wyświetlany link do wyświetlania podsumowania odpowiedzi po wypełnieniu przez użytkownika formularza.
isQuiz()BooleanOkreśla, czy formularz jest quizem.
moveItem(from, to)ItemPrzenosi element w danym indeksie do wszystkich elementów w formularzu do innego danego indeksu.
moveItem(item, toIndex)ItemPrzenosi dany element do danego indeksu wśród wszystkich elementów w formularzu.
removeDestination()FormOdłącza formularz od bieżącego miejsca docelowego odpowiedzi.
removeEditor(emailAddress)FormUsunięcie tego użytkownika z listy edytorów Form.
removeEditor(user)FormUsunięcie tego użytkownika z listy edytorów Form.
requiresLogin()BooleanOkreśla, czy przed wysłaniem formularza użytkownik musi zalogować się na konto w tej samej domenie lub subdomenie.
setAcceptingResponses(enabled)FormOkreśla, czy formularz przyjmuje obecnie odpowiedzi.
setAllowResponseEdits(enabled)FormOkreśla, czy po przesłaniu formularza w formularzu ma być edytowany link.
setCollectEmail(collect)FormOkreśla, czy formularz zbiera adresy e-mail użytkowników.
setConfirmationMessage(message)FormUstawia komunikat z potwierdzeniem formularza.
setCustomClosedFormMessage(message)FormUmożliwia wyświetlanie wiadomości, jeśli formularz nie przyjmuje odpowiedzi.
setDescription(description)FormUstawia opis formularza.
setDestination(type, id)FormUstawia miejsce docelowe zapisywania odpowiedzi z formularza.
setIsQuiz(enabled)FormOkreśla, czy formularz jest testem.
setLimitOneResponsePerUser(enabled)FormOkreśla, czy w formularzu można odpowiedzieć tylko raz na użytkownika.
setProgressBar(enabled)FormOkreśla, czy formularz ma pasek postępu.
setPublishingSummary(enabled)FormOkreśla, czy w formularzu ma być wyświetlany link do podsumowania odpowiedzi po przesłaniu przez użytkownika formularza.
setRequireLogin(requireLogin)FormOkreśla, czy przed wypełnieniem formularza użytkownicy muszą logować się na konto w tej samej domenie lub subdomenie.
setShowLinkToRespondAgain(enabled)FormOkreśla, czy w formularzu ma się pojawić link umożliwiający przesłanie kolejnej odpowiedzi po wypełnieniu formularza.
setShuffleQuestions(shuffle)FormOkreśla kolejność pytań na każdej stronie formularza.
setTitle(title)FormOkreśla tytuł formularza.
shortenFormUrl(url)StringKonwertuje długi adres URL formularza na krótki adres URL.
submitGrades(responses)FormPrzekazuje oceny dla podanych odpowiedzi.

Szczegółowa dokumentacja

addCheckboxGridItem()

Dodaje nowy element pytania w formie siatki i wierszy, które pozwalają ankietowanym wybrać kilka opcji w danym wierszu z sekwencji pól wyboru.

// 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']);

Powrót

CheckboxGridItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addCheckboxItem()

Dodaje nowy element pytania, który pozwala respondentowi wybrać co najmniej jedno pole wyboru, a także opcjonalne pole „inne”.

// 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']);

Powrót

CheckboxItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addDateItem()

Dodaje nowy element pytania, który umożliwia respondentowi określenie daty.

// 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.');

Powrót

DateItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addDateTimeItem()

Dodaje nowy element pytania, który umożliwia respondentowi określenie daty i godziny.

// 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);

Powrót

DateTimeItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addDurationItem()

Dodaje nowy element pytania, który umożliwia respondentowi wskazanie czasu trwania.

// 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);

Powrót

DurationItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addEditor(emailAddress)

Dodaje danego użytkownika do listy edytorów elementu Form. Jeśli użytkownik był już na liście widzów, ta metoda przenosi go z listy.

Parametry

NazwaTypOpis
emailAddressStringAdres e-mail użytkownika, którego chcesz dodać.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addEditor(user)

Dodaje danego użytkownika do listy edytorów elementu Form. Jeśli użytkownik był już na liście widzów, ta metoda przenosi go z listy.

Parametry

NazwaTypOpis
userUserReprezentacja użytkownika do dodania.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addEditors(emailAddresses)

Dodaje podaną tablicę użytkowników do listy edytorów obiektu Form. Jeśli którykolwiek z użytkowników znajduje się już na liście widzów, ta metoda przenosi ich na listę widzów.

Parametry

NazwaTypOpis
emailAddressesString[]Tablica adresów e-mail użytkowników do dodania.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addGridItem()

Dodaje nowy element pytania w formie siatki kolumn i wierszy, umożliwiając respondentowi wybranie jednej odpowiedzi w wierszu.

// 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']);

Powrót

GridItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addImageItem()

Dołącza nowy element układu, który wyświetla obraz.

// 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);

Powrót

ImageItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addListItem()

Dodaje nowy element pytania, który umożliwia respondentowi wybór jednego z listy.

// 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')
]);

Powrót

ListItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addMultipleChoiceItem()

Dodaje nowy element pytania, który umożliwia respondentowi wybranie jednego z przycisku lub opcjonalnego pola „inne”.

// 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]);

Powrót

MultipleChoiceItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addPageBreakItem()

Dodaje nowy element układu, który wyznacza początek strony.

// 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);

Powrót

PageBreakItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addParagraphTextItem()

Dodaje nowy element pytania, który umożliwia respondentowi wpisanie bloku tekstu.

// 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?');

Powrót

ParagraphTextItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addScaleItem()

Dołącza nowy element pytania, który pozwala respondentowi wybrać jedną z następujących po sobie przycisków opcji.

// 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');

Powrót

ScaleItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addSectionHeaderItem()

Zawiera nowy element układu, który wskazuje początek sekcji.

 // 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');

Powrót

SectionHeaderItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addTextItem()

Dodaje nowy element pytania, który pozwala respondentowi wpisać jeden wiersz tekstu.

// 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?');

Powrót

TextItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addTimeItem()

Dodaje nowy element pytania, który pozwala ankietowanym określić godzinę.

// 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?');

Powrót

TimeItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

addVideoItem()

Dołącza nowy element układu, który wyświetla film.

// 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);

Powrót

VideoItem – nowo utworzony element.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

canEditResponse()

Określa, czy po przesłaniu formularza w formularzu ma być edytowany link.

Niezależnie od tego ustawienia metoda FormResponse.getEditResponseUrl() pozwala autorowi skryptu mającym uprawnienia do edycji formularza na wygenerowanie adresu URL, którego można użyć do edytowania odpowiedzi.

// 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);

Powrót

Booleantrue, jeśli formularz zawiera link „Edytuj odpowiedź”; false, jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

collectsEmail()

Określa, czy formularz zbiera adresy e-mail użytkowników.

// 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);

Powrót

Booleantrue, jeśli formularz zbiera adresy e-mail; false, jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

createResponse()

Tworzy nową odpowiedź na formularz. Aby odpowiedzieć na pytanie, utwórz ItemResponse z tego elementu, a następnie dołącz go do tej odpowiedzi, wywołując FormResponse.withItemResponse(response). Aby zapisać złożoną odpowiedź, wywołaj: FormResponse.submit().

Powrót

FormResponse – nowo utworzona odpowiedź z formularza.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

deleteAllResponses()

spowoduje usunięcie wszystkich przesłanych odpowiedzi z magazynu odpowiedzi. Ta metoda nie powoduje usunięcia kopii odpowiedzi przechowywanych w zewnętrznym miejscu docelowym odpowiedzi (takich jak arkusz kalkulacyjny), ale powoduje wyczyszczenie widoku podsumowania formularza.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

deleteItem(index)

Usuwa element o danym indeksie ze wszystkich elementów w formularzu. Zwraca wyjątek skryptu, jeśli pod danym indeksem nie ma elementu.

// 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);
}

Parametry

NazwaTypOpis
indexIntegerIndeks elementu wśród wszystkich elementów w formularzu.

Narzuty

Error – jeśli w danym indeksie nie ma żadnego elementu,

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

deleteItem(item)

Usuwa dany element. Zwraca wyjątek skryptu, jeśli element został już usunięty.

// 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);
}

Parametry

NazwaTypOpis
itemItemElement do usunięcia.

Narzuty

Error – jeśli element nie istnieje w formularzu,

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

deleteResponse(responseId)

Usuwa pojedynczą odpowiedź z magazynu odpowiedzi z formularza. Ta metoda nie powoduje usunięcia kopii odpowiedzi przechowywanych w zewnętrznym miejscu docelowym odpowiedzi (np. arkusza kalkulacyjnego), ale usuwa odpowiedź z widoku podsumowania formularza. Identyfikator odpowiedzi można pobrać w formacie FormResponse.getId().

Parametry

NazwaTypOpis
responseIdStringIdentyfikator odpowiedzi z formularza, którą chcesz usunąć.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getConfirmationMessage()

Pobiera wiadomość z potwierdzeniem formularza.

// 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);

Powrót

String – komunikat z potwierdzeniem formularza,

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getCustomClosedFormMessage()

Pobiera komunikat niestandardowy wyświetlany, jeśli formularz nie przyjmuje odpowiedzi, lub pusty ciąg, jeśli nie jest ustawiona żadna wiadomość niestandardowa.

// 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);

Powrót

String – komunikat niestandardowy wyświetlany w formularzu, który nie przyjmuje odpowiedzi, lub pusty ciąg znaków, jeśli nie jest ustawiona żadna wiadomość niestandardowa.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getDescription()

Pobiera opis formularza.

// 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);

Powrót

String – opis formularza;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getDestinationId()

Pobiera identyfikator miejsca docelowego odpowiedzi z formularza.

// 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);

Powrót

String – identyfikator miejsca docelowego odpowiedzi na formularz;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getDestinationType()

Pobiera typ miejsca docelowego odpowiedzi na formularz.

// 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);

Powrót

DestinationType – typ miejsca docelowego odpowiedzi na formularz.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getEditUrl()

Pobiera adres URL, który może służyć do uzyskiwania dostępu do trybu edycji formularza.

// 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);

Powrót

String – adres URL służący do edytowania formularza;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getEditors()

Pobiera listę edytorów na koncie Form.

Powrót

User[] – tablica użytkowników z uprawnieniami do edycji.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getId()

Pobiera identyfikator formularza.

// 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);

Powrót

String – identyfikator formularza;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getItemById(id)

Pobiera element o podanym identyfikatorze. Zwraca wartość null, jeśli identyfikator nie odpowiada elementowi w formularzu.

// 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);

Parametry

NazwaTypOpis
idIntegerIdentyfikator produktu.

Powrót

Item – element o podanym identyfikatorze lub null, jeśli element nie istnieje w formularzu;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getItems()

Pobiera tablicę ze wszystkimi elementami w formularzu.

// 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);

Powrót

Item[] – tablica ze wszystkimi elementami w formularzu;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getItems(itemType)

Pobiera tablicę ze wszystkimi elementami danego typu.

// 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);

Parametry

NazwaTypOpis
itemTypeItemTypeTyp elementów do pobrania.

Powrót

Item[] – tablica ze wszystkimi elementami danego typu;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getPublishedUrl()

Pobiera adres URL, którego można użyć do odpowiedzi na formularz.

// 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);

Powrót

String – adres URL odpowiadający na formularz;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getResponse(responseId)

Pobiera odpowiedź z 1 formularza na podstawie jej identyfikatora. Identyfikatory odpowiedzi można pobrać z FormResponse.getId().

Parametry

NazwaTypOpis
responseIdStringIdentyfikator odpowiedzi na formularz.

Powrót

FormResponse – odpowiedź z formularza.

Narzuty

Error – jeśli odpowiedź nie istnieje.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getResponses()

Pobiera tablicę ze wszystkimi odpowiedziami z formularza.

Powrót

FormResponse[] – tablica wszystkich odpowiedzi w formularzu;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getResponses(timestamp)

Pobiera tablicę ze wszystkimi odpowiedziami z danego formularza po określonej dacie i godzinie.

Parametry

NazwaTypOpis
timestampDateNajwcześniejsza data i godzina odpowiedzi na formularz.

Powrót

FormResponse[] – lista odpowiedzi na pytania z formularza.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getShuffleQuestions()

Określa kolejność pytań na każdej stronie formularza.

Powrót

Booleantrue, jeśli kolejność pytań na każdej stronie formularza jest losowa. false, jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getSummaryUrl()

Pobiera adres URL, którego można używać do wyświetlania podsumowania odpowiedzi z formularza. Tylko użytkownicy z uprawnieniami do edycji formularza mogą uzyskać dostęp do adresu URL, chyba że setPublishingSummary(enabled) ma wartość 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.
// 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);

Powrót

String – adres URL służący do wyświetlania podsumowania odpowiedzi.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

getTitle()

Pobiera tytuł formularza.

// 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);

Powrót

String – tytuł formularza;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

hasLimitOneResponsePerUser()

Określa, czy w formularzu można odpowiedzieć tylko raz na użytkownika. Jeśli wartość to true, skrypt nie może w ogóle przesyłać odpowiedzi na formularz.

Powrót

Booleantrue, jeśli formularz zezwala na tylko 1 odpowiedź na użytkownika; false – jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

hasProgressBar()

Określa, czy formularz ma wyświetlać pasek postępu.

// 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());

Powrót

Booleantrue, jeśli formularz zawiera pasek postępu, a false – jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

Określa, czy w formularzu wyświetla się link do przesyłania kolejnej odpowiedzi.

// 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());

Powrót

Booleantrue, jeśli formularz zawiera link „Prześlij kolejną odpowiedź”, a false – jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

isAcceptingResponses()

Określa, czy formularz przyjmuje obecnie odpowiedzi.

// 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);

Powrót

Booleantrue, jeśli formularz przyjmuje odpowiedzi; false, jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

isPublishingSummary()

Określa, czy w formularzu jest wyświetlany link do wyświetlania podsumowania odpowiedzi po wypełnieniu przez użytkownika formularza.

// 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);

Powrót

Booleantrue, jeśli formularz zawiera link „Zobacz poprzednie odpowiedzi”, a false – jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

isQuiz()

Określa, czy formularz jest quizem.

// 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());

Powrót

Booleantrue, jeśli formularz przyjmuje odpowiedzi; false, jeśli nie.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

moveItem(from, to)

Przenosi element w danym indeksie do wszystkich elementów w formularzu do innego danego indeksu. Zwraca wyjątek skryptu, jeśli indeks to jest poza zakresem.

// 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);

Parametry

NazwaTypOpis
fromIntegerBieżący indeks elementu wśród wszystkich elementów w formularzu.
toIntegerNowy indeks elementu wśród wszystkich elementów w formularzu.

Powrót

Item – element, który został przeniesiony;

Narzuty

Error – jeśli któryś z indeksów jest poza zakresem.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

moveItem(item, toIndex)

Przenosi dany element do danego indeksu wśród wszystkich elementów w formularzu. Rzuca wyjątek skryptu, jeśli podany indeks jest poza zakresem.

// 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);

Parametry

NazwaTypOpis
itemItemElement do przeniesienia.
toIndexIntegerNowy indeks elementu wśród wszystkich elementów w formularzu.

Powrót

Item – element, który został przeniesiony;

Narzuty

Error – jeśli indeks jest poza zakresem.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

removeDestination()

Odłącza formularz od bieżącego miejsca docelowego odpowiedzi. Odłączone poprzednie miejsce docelowe nadal zawiera kopię wszystkich poprzednich odpowiedzi. Wszystkie formularze, w tym te, które nie mają wyraźnie ustawionego miejsca docelowego, zapisz kopię odpowiedzi w magazynie odpowiedzi. Jeśli formularz nie ma obecnie miejsca docelowego odpowiedzi, ta metoda nie daje żadnego efektu.

// 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();

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

removeEditor(emailAddress)

Usunięcie tego użytkownika z listy edytorów Form. Ta metoda nie blokuje dostępu do Form, jeśli należą one do grupy użytkowników, którzy mają dostęp ogólny, na przykład jeśli Form jest udostępniany w całej domenie użytkownika lub gdy Form znajduje się na dysku współdzielonym, do którego ma dostęp użytkownik.

W przypadku plików na Dysku również zostanie on usunięty z listy przeglądających.

Parametry

NazwaTypOpis
emailAddressStringAdres e-mail użytkownika, którego chcesz usunąć.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

removeEditor(user)

Usunięcie tego użytkownika z listy edytorów Form. Ta metoda nie blokuje dostępu do Form, jeśli należą one do grupy użytkowników, którzy mają dostęp ogólny, na przykład jeśli Form jest udostępniany w całej domenie użytkownika lub gdy Form znajduje się na dysku współdzielonym, do którego ma dostęp użytkownik.

W przypadku plików na Dysku również zostanie on usunięty z listy przeglądających.

Parametry

NazwaTypOpis
userUserReprezentacja użytkownika do usunięcia.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

requiresLogin()

Określa, czy przed wysłaniem formularza użytkownik musi zalogować się na konto w tej samej domenie lub subdomenie.

// 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);

Powrót

Booleantrue, jeśli formularz wymaga od użytkowników zalogowania się; false – jeśli nie.


setAcceptingResponses(enabled)

Określa, czy formularz przyjmuje obecnie odpowiedzi. Domyślnie nowe formularze to 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());

Parametry

NazwaTypOpis
enabledBooleantrue – jeśli formularz powinien akceptować odpowiedzi; false – jeśli nie.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setAllowResponseEdits(enabled)

Określa, czy po przesłaniu formularza w formularzu ma być edytowany link. Domyślnie nowe formularze to false.

Niezależnie od tego ustawienia metoda FormResponse.getEditResponseUrl() pozwala autorowi skryptu mieć uprawnienia do edycji formularza na wygenerowanie adresu URL, którego można użyć do edytowania odpowiedzi.

// 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());

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli formularz powinien zawierać link „Edytuj odpowiedź”. Jeśli nie, false.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setCollectEmail(collect)

Określa, czy formularz zbiera adresy e-mail użytkowników. Domyślnie nowe formularze to 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);

Parametry

NazwaTypOpis
collectBooleantrue, jeśli formularz powinien zbierać adresy e-mail; false, jeśli nie.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setConfirmationMessage(message)

Ustawia komunikat z potwierdzeniem formularza.

// 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);

Parametry

NazwaTypOpis
messageStringNowa wiadomość z potwierdzeniem w formularzu.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setCustomClosedFormMessage(message)

Umożliwia wyświetlanie wiadomości, jeśli formularz nie przyjmuje odpowiedzi. Jeśli nie ustawisz żadnej wiadomości, formularz użyje wiadomości domyślnej.

// 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);

Parametry

NazwaTypOpis
messageStringKomunikat wyświetlany w formularzu, który nie przyjmuje odpowiedzi.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setDescription(description)

Ustawia opis formularza.

Parametry

NazwaTypOpis
descriptionStringNowy opis formularza.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setDestination(type, id)

Ustawia miejsce docelowe zapisywania odpowiedzi z formularza. Wszystkie formularze, w tym te, które nie mają wyraźnie ustawionego miejsca docelowego, zapisz kopię odpowiedzi w magazynie odpowiedzi.

Parametry

NazwaTypOpis
typeDestinationTypeTyp miejsca docelowego odpowiedzi na formularz.
idStringIdentyfikator miejsca docelowego odpowiedzi na formularz.

Powrót

FormForm w celu tworzenia łańcuchów.

Narzuty

Error – jeśli podany identyfikator miejsca docelowego jest nieprawidłowy;

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setIsQuiz(enabled)

Określa, czy formularz jest testem. Domyślnie nowe formularze to false.

Oceniane pytania są dozwolone tylko w quizach. Jeśli więc ustawisz wartość false, wszystkie opcje oceniania zostaną usunięte ze wszystkich pytań.

Ustawienia quizu są dostępne tylko w nowym interfejsie Formularzy. Utworzenie testu powoduje włączenie w nim nowego interfejsu.

// 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());

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli w formularzu powinny być włączone funkcje quizu. Jeśli nie, false.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setLimitOneResponsePerUser(enabled)

Określa, czy w formularzu można odpowiedzieć tylko raz na użytkownika. Domyślnie nowe formularze to false. Jeśli wartość to true, skrypt w ogóle nie może przesyłać odpowiedzi na pytania.

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli formularz powinien zawierać tylko jedną odpowiedź na użytkownika. false – jeśli nie.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setProgressBar(enabled)

Określa, czy formularz ma pasek postępu. Domyślnie nowe formularze to 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());

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli formularz zawiera pasek postępu, a false, jeśli nie.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setPublishingSummary(enabled)

Określa, czy w formularzu ma być wyświetlany link do podsumowania odpowiedzi po przesłaniu przez użytkownika formularza. Domyślnie nowe formularze to false.

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli formularz powinien zawierać link „Zobacz poprzednie odpowiedzi”. Jeśli nie, false.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setRequireLogin(requireLogin)

Określa, czy przed wypełnieniem formularza użytkownicy muszą logować się na konto w tej samej domenie lub subdomenie. Domyślnie nowe formularze mają wartość false, chyba że administrator domeny zmieni wartość domyślną.

Ta funkcja jest dostępna tylko w przypadku formularzy utworzonych przez użytkowników Google Workspace. Użytkownicy innych typów kont Google nie mogą być zmuszeni do zalogowania się.

// 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());

Parametry

NazwaTypOpis
requireLoginBooleantrue, jeśli formularz wymaga od użytkowników zalogowania się; false – jeśli nie.

Powrót

Form – bieżąca forma (do łańcucha).

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setShowLinkToRespondAgain(enabled)

Określa, czy w formularzu ma się pojawić link umożliwiający przesłanie kolejnej odpowiedzi po wypełnieniu formularza. Domyślnie nowe formularze to true.

Parametry

NazwaTypOpis
enabledBooleantrue, jeśli formularz powinien zawierać link „Prześlij kolejną odpowiedź”. Jeśli nie, false.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setShuffleQuestions(shuffle)

Określa kolejność pytań na każdej stronie formularza.

Parametry

NazwaTypOpis
shuffleBooleantrue, jeśli kolejność pytań na każdej stronie formularza powinna być losowa. false, jeśli nie.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

setTitle(title)

Określa tytuł formularza.

Parametry

NazwaTypOpis
titleStringNowy tytuł formularza.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

shortenFormUrl(url)

Konwertuje długi adres URL formularza na krótki adres URL. Wyjątek, jeśli długi URL nie dotyczy Formularzy Google.

Parametry

NazwaTypOpis
urlStringAdres URL do skrócenia.

Powrót

String – adres URL w formacie http://goo.gl/forms/1234,

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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

submitGrades(responses)

Przekazuje oceny dla podanych odpowiedzi.

Jeśli Twój kod zawiera aktywator onFormSubmit, wywołanie metody submitGrades() wywołuje warunek onFormSubmit i pętlę nieskończoną. Aby zapobiec nieskończonej pętli, przed wywołaniem funkcji submitGrades() dodaj kod, który sprawdza, czy oceny już istnieją.

Parametry

NazwaTypOpis
responsesFormResponse[]Tablica wszystkich odpowiedzi na formularz.

Powrót

FormForm w celu tworzenia łańcuchów.

Upoważnienie

Skrypty korzystające z tej metody wymagają autoryzacji za pomocą co najmniej jednego z tych zakresów:

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