Class Form

Form

Ein Formular, das allgemeine Eigenschaften und Elemente enthält. Zu den Eigenschaften gehören Titel, Einstellungen und der Speicherort der Antworten. Zu den Elementen gehören Frageelemente wie Kästchen oder Optionsfelder, während sich Layout-Elemente auf Dinge wie Seitenumbrüche beziehen. Über FormApp können Sie auf Formulare zugreifen oder sie erstellen.

// Open a form by ID and create a new spreadsheet.
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
const 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());

Methoden

MethodeRückgabetypKurzbeschreibung
addCheckboxGridItem()CheckboxGridItemFügt ein neues Frageelement ein, das als Raster aus Spalten und Zeilen dargestellt wird. Der Teilnehmer kann in jeder Zeile mehrere Optionen aus einer Reihe von Kästchen auswählen.
addCheckboxItem()CheckboxItemFügt ein neues Frageelement hinzu, in dem der Teilnehmer ein oder mehrere Kästchen sowie optional ein Feld „Sonstiges“ auswählen kann.
addDateItem()DateItemFügt ein neues Frageelement hinzu, in dem der Befragte ein Datum angeben kann.
addDateTimeItem()DateTimeItemFügt ein neues Frageelement hinzu, in dem der Befragte ein Datum und eine Uhrzeit angeben kann.
addDurationItem()DurationItemFügt ein neues Frageelement hinzu, mit dem der Befragte einen Zeitraum angeben kann.
addEditor(emailAddress)FormFügt den angegebenen Nutzer der Liste der Bearbeiter für die Form hinzu.
addEditor(user)FormFügt den angegebenen Nutzer der Liste der Bearbeiter für die Form hinzu.
addEditors(emailAddresses)FormFügt das angegebene Nutzer-Array der Liste der Bearbeiter für Form hinzu.
addGridItem()GridItemFügt ein neues Frageelement hinzu, das als Raster aus Spalten und Zeilen dargestellt wird. Der Teilnehmer kann pro Zeile eine Option aus einer Reihe von Optionsfeldern auswählen.
addImageItem()ImageItemFügt ein neues Layout-Element hinzu, in dem ein Bild angezeigt wird.
addListItem()ListItemFügt ein neues Frageelement hinzu, mit dem der Befragte eine Option aus einer Drop-down-Liste auswählen kann.
addMultipleChoiceItem()MultipleChoiceItemFügt ein neues Frageelement hinzu, mit dem der Befragte eine Option aus einer Liste von Optionsfeldern oder ein optionales Feld „Sonstiges“ auswählen kann.
addPageBreakItem()PageBreakItemFügt ein neues Layoutelement hinzu, das den Beginn einer Seite markiert.
addParagraphTextItem()ParagraphTextItemFügt ein neues Frageelement hinzu, in dem der Befragte einen Textblock eingeben kann.
addPublishedReader(emailAddress)FormFügt den angegebenen Nutzer der Liste der Antwortenden für die Form hinzu.
addPublishedReader(user)FormFügt den angegebenen Nutzer der Liste der Antwortenden für die Form hinzu.
addPublishedReaders(emailAddresses)FormFügt das angegebene Nutzer-Array der Liste der Antwortenden für Form hinzu.
addRatingItem()RatingItemFügt ein neues Frageelement hinzu, mit dem der Befragte eine Bewertung abgeben kann.
addScaleItem()ScaleItemFügt ein neues Frageelement hinzu, mit dem der Umfrageteilnehmer eine Option aus einer nummerierten Reihe von Optionsfeldern auswählen kann.
addSectionHeaderItem()SectionHeaderItemFügt ein neues Layout-Element hinzu, das den Beginn eines Abschnitts visuell kennzeichnet.
addTextItem()TextItemFügt ein neues Frageelement hinzu, in das der Befragte eine einzelne Textzeile eingeben kann.
addTimeItem()TimeItemFügt ein neues Frageelement hinzu, mit dem der Teilnehmer eine Tageszeit angeben kann.
addVideoItem()VideoItemFügt ein neues Layout-Element hinzu, in dem ein Video angezeigt wird.
canEditResponse()BooleanBestimmt, ob im Formular nach dem Senden einer Antwort ein Link zum Bearbeiten der Antwort angezeigt wird.
collectsEmail()BooleanGibt an, ob im Formular die E‑Mail-Adressen der Umfrageteilnehmer erfasst werden.
createResponse()FormResponseErstellt eine neue Antwort auf das Formular.
deleteAllResponses()FormLöscht alle eingereichten Antworten aus dem Antwortspeicher des Formulars.
deleteItem(index)voidLöscht das Element an einem bestimmten Index unter allen Elementen im Formular.
deleteItem(item)voidLöscht das angegebene Element.
deleteResponse(responseId)FormLöscht eine einzelne Antwort aus dem Antwortspeicher des Formulars.
getConfirmationMessage()StringRuft die Bestätigungsnachricht des Formulars ab.
getCustomClosedFormMessage()StringRuft die benutzerdefinierte Nachricht ab, die angezeigt wird, wenn für das Formular keine Antworten angenommen werden, oder einen leeren String, wenn keine benutzerdefinierte Nachricht festgelegt ist.
getDescription()StringRuft die Beschreibung des Formulars ab.
getDestinationId()StringRuft die ID des Antwortziels des Formulars ab.
getDestinationType()DestinationTypeGibt den Typ des Antwortziels des Formulars zurück.
getEditUrl()StringRuft die URL ab, über die auf den Bearbeitungsmodus des Formulars zugegriffen werden kann.
getEditors()User[]Ruft die Liste der Mitbearbeiter für diese Form ab.
getId()StringRuft die ID des Formulars ab.
getItemById(id)Item|nullRuft das Element mit einer bestimmten ID ab.
getItems()Item[]Ruft ein Array aller Elemente im Formular ab.
getItems(itemType)Item[]Ruft ein Array aller Elemente eines bestimmten Typs ab.
getPublishedReaders()User[]Ruft die Liste der Antworten für diese Form ab.
getPublishedUrl()StringGibt die URL zurück, die zum Beantworten des Formulars verwendet werden kann.
getResponse(responseId)FormResponseRuft eine einzelne Formularantwort anhand ihrer Antwort-ID ab.
getResponses()FormResponse[]Ruft ein Array mit allen Antworten des Formulars ab.
getResponses(timestamp)FormResponse[]Ruft ein Array aller Antworten des Formulars nach einem bestimmten Datum und einer bestimmten Uhrzeit ab.
getShuffleQuestions()BooleanGibt an, ob die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig ist.
getSummaryUrl()StringRuft die URL ab, die zum Aufrufen einer Zusammenfassung der Antworten des Formulars verwendet werden kann.
getTitle()StringRuft den Titel des Formulars ab.
hasLimitOneResponsePerUser()BooleanGibt an, ob das Formular nur eine Antwort pro Antwortgeber zulässt.
hasProgressBar()BooleanLegt fest, ob im Formular eine Fortschrittsanzeige zu sehen ist.
hasRespondAgainLink()BooleanBestimmt, ob im Formular ein Link zum Senden einer weiteren Antwort angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat.
isAcceptingResponses()BooleanGibt an, ob für das Formular derzeit Antworten angenommen werden.
isPublished()BooleanGibt an, ob das Formular veröffentlicht wird.
isPublishingSummary()BooleanGibt an, ob im Formular ein Link zum Aufrufen einer Zusammenfassung der Antworten angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat.
isQuiz()BooleanGibt an, ob es sich bei dem Formular um ein Quiz handelt.
moveItem(from, to)ItemVerschiebt ein Element an einem bestimmten Index unter allen Elementen im Formular an einen anderen bestimmten Index.
moveItem(item, toIndex)ItemVerschiebt ein bestimmtes Element an einen bestimmten Index unter allen Elementen im Formular.
removeDestination()FormHebt die Verknüpfung des Formulars mit dem aktuellen Antwortziel auf.
removeEditor(emailAddress)FormEntfernt den angegebenen Nutzer aus der Liste der Mitbearbeiter für die Form.
removeEditor(user)FormEntfernt den angegebenen Nutzer aus der Liste der Mitbearbeiter für die Form.
removePublishedReader(emailAddress)FormEntfernt den angegebenen Nutzer aus der Liste der Antwortenden für die Form.
removePublishedReader(user)FormEntfernt den angegebenen Nutzer aus der Liste der Antwortenden für die Form.
setAcceptingResponses(enabled)FormLegt fest, ob für das Formular derzeit Antworten angenommen werden.
setAllowResponseEdits(enabled)FormLegt fest, ob im Formular nach dem Senden einer Antwort ein Link zum Bearbeiten der Antwort angezeigt wird.
setCollectEmail(collect)FormLegt fest, ob im Formular die E‑Mail-Adressen der Umfrageteilnehmer erfasst werden.
setConfirmationMessage(message)FormLegt die Bestätigungsnachricht des Formulars fest.
setCustomClosedFormMessage(message)FormLegt die Meldung fest, die angezeigt werden soll, wenn für das Formular keine Antworten akzeptiert werden.
setDescription(description)FormLegt die Beschreibung des Formulars fest.
setDestination(type, id)FormLegt das Ziel fest, in dem Formularantworten gespeichert werden.
setIsQuiz(enabled)FormLegt fest, ob das Formular ein Quiz ist.
setLimitOneResponsePerUser(enabled)FormLegt fest, ob das Formular nur eine Antwort pro Teilnehmer zulässt.
setProgressBar(enabled)FormLegt fest, ob das Formular eine Fortschrittsanzeige hat.
setPublished(enabled)FormLegt fest, ob das Formular veröffentlicht wird.
setPublishingSummary(enabled)FormLegt fest, ob im Formular ein Link zum Anzeigen einer Zusammenfassung der Antworten angezeigt wird, nachdem ein Teilnehmer das Formular gesendet hat.
setShowLinkToRespondAgain(enabled)FormLegt fest, ob im Formular ein Link zum Senden einer weiteren Antwort angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat.
setShuffleQuestions(shuffle)FormLegt fest, ob die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig ist.
setTitle(title)FormLegt den Titel des Formulars fest.
shortenFormUrl(url)StringWandelt eine lange URL für ein Formular in eine kurze URL um.
submitGrades(responses)FormReicht Noten für die angegebenen FormResponses ein.
supportsAdvancedResponderPermissions()BooleanGibt an, ob das Formular die Veröffentlichung unterstützt.

Detaillierte Dokumentation

addCheckboxGridItem()

Fügt ein neues Frageelement ein, das als Raster aus Spalten und Zeilen dargestellt wird. Der Teilnehmer kann in jeder Zeile mehrere Optionen aus einer Reihe von Kästchen auswählen.

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

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

Rückflug

CheckboxGridItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addCheckboxItem()

Fügt ein neues Frageelement hinzu, in dem der Teilnehmer ein oder mehrere Kästchen sowie optional ein Feld „Sonstiges“ auswählen kann.

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

Rückflug

CheckboxItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addDateItem()

Fügt ein neues Frageelement hinzu, in dem der Befragte ein Datum angeben kann.

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

Rückflug

DateItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addDateTimeItem()

Fügt ein neues Frageelement hinzu, in dem der Befragte ein Datum und eine Uhrzeit angeben kann.

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

Rückflug

DateTimeItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addDurationItem()

Fügt ein neues Frageelement hinzu, mit dem der Befragte einen Zeitraum angeben kann.

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

Rückflug

DurationItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addEditor(emailAddress)

Fügt den angegebenen Nutzer der Liste der Bearbeiter für die Form hinzu. Wenn der Nutzer bereits in der Liste der Zuschauer oder Antwortenden enthalten war, wird er durch diese Methode aus der Liste entfernt.

// 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 editor to the form.
// TODO(developer): replace the emailAddress.
form.addEditor('editor@uni.edu');

Parameter

NameTypBeschreibung
emailAddressStringDie E-Mail-Adresse des Nutzers, den Sie hinzufügen möchten.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addEditor(user)

Fügt den angegebenen Nutzer der Liste der Bearbeiter für die Form hinzu. Wenn der Nutzer bereits in der Liste der Zuschauer oder Antwortenden enthalten war, wird er durch diese Methode aus der Liste entfernt.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the editors from the old form.
const users = oldForm.getEditors();

// Creates a new form.
const newForm = FormApp.create('New form');

// Adds the editors to a new form.
users.forEach(user => newForm.addEditor(user));

Parameter

NameTypBeschreibung
userUserEine Darstellung des hinzuzufügenden Nutzers.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addEditors(emailAddresses)

Fügt das angegebene Nutzer-Array der Liste der Bearbeiter für Form hinzu. Wenn sich einer der Nutzer bereits in der Liste der Zuschauer befand, wird er durch diese Methode aus der Liste der Zuschauer entfernt.

// 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 editors to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReaders(['editor1@uni.edu', 'editor2@uni.edu']);

Parameter

NameTypBeschreibung
emailAddressesString[]Ein Array mit den E‑Mail-Adressen der Nutzer, die hinzugefügt werden sollen.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addGridItem()

Fügt ein neues Frageelement hinzu, das als Raster aus Spalten und Zeilen dargestellt wird. Der Teilnehmer kann pro Zeile eine Option aus einer Reihe von Optionsfeldern auswählen.

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

Rückflug

GridItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addImageItem()

Fügt ein neues Layout-Element hinzu, in dem ein Bild angezeigt wird.

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

Rückflug

ImageItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addListItem()

Fügt ein neues Frageelement hinzu, mit dem der Befragte eine Option aus einer Drop-down-Liste auswählen kann.

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

Rückflug

ListItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addMultipleChoiceItem()

Fügt ein neues Frageelement hinzu, mit dem der Befragte eine Option aus einer Liste von Optionsfeldern oder ein optionales Feld „Sonstiges“ auswählen kann.

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

Rückflug

MultipleChoiceItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addPageBreakItem()

Fügt ein neues Layoutelement hinzu, das den Beginn einer Seite markiert.

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

Rückflug

PageBreakItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addParagraphTextItem()

Fügt ein neues Frageelement hinzu, in dem der Befragte einen Textblock eingeben kann.

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

Rückflug

ParagraphTextItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addPublishedReader(emailAddress)

Fügt den angegebenen Nutzer der Liste der Antwortenden für die Form hinzu. Wenn der Nutzer bereits in der Liste der Bearbeiter oder Betrachter war, hat diese Methode keine Auswirkungen.

// 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 responder to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReader('responder@uni.edu');

Parameter

NameTypBeschreibung
emailAddressStringDie E-Mail-Adresse des Nutzers, den Sie hinzufügen möchten.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addPublishedReader(user)

Fügt den angegebenen Nutzer der Liste der Antwortenden für die Form hinzu. Wenn der Nutzer bereits in der Liste der Bearbeiter oder Betrachter war, hat diese Methode keine Auswirkungen.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the responders from the old form.
const users = oldForm.getPublishedReaders();

// Creates a new form.
const newForm = FormApp.create('New form');

// Adds the responders to a new form.
users.forEach(user => newForm.addPublishedReader(user));

Parameter

NameTypBeschreibung
userUserEine Darstellung des hinzuzufügenden Nutzers.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addPublishedReaders(emailAddresses)

Fügt das angegebene Nutzer-Array der Liste der Antwortenden für Form hinzu. Wenn der Nutzer bereits in der Liste der Bearbeiter oder Betrachter enthalten war, hat diese Methode keine Auswirkungen.

// 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 responders to the form.
// TODO(developer): replace the emailAddress.
form.addPublishedReaders(['responder1@uni.edu', 'responder2@uni.edu']);

Parameter

NameTypBeschreibung
emailAddressesString[]Ein Array mit den E‑Mail-Adressen der Nutzer, die hinzugefügt werden sollen.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addRatingItem()

Fügt ein neues Frageelement hinzu, mit dem der Befragte eine Bewertung abgeben kann.

// 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 rating item.
const item = form.addRatingItem();

Rückflug

RatingItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addScaleItem()

Fügt ein neues Frageelement hinzu, mit dem der Umfrageteilnehmer eine Option aus einer nummerierten Reihe von Optionsfeldern auswählen kann.

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

Rückflug

ScaleItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addSectionHeaderItem()

Fügt ein neues Layout-Element hinzu, das den Beginn eines Abschnitts visuell kennzeichnet.

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

Rückflug

SectionHeaderItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addTextItem()

Fügt ein neues Frageelement hinzu, in das der Befragte eine einzelne Textzeile eingeben kann.

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

Rückflug

TextItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addTimeItem()

Fügt ein neues Frageelement hinzu, mit dem der Teilnehmer eine Tageszeit angeben kann.

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

Rückflug

TimeItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

addVideoItem()

Fügt ein neues Layout-Element hinzu, in dem ein Video angezeigt wird.

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

Rückflug

VideoItem: Das neu erstellte Element.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

canEditResponse()

Bestimmt, ob im Formular nach dem Senden einer Antwort ein Link zum Bearbeiten der Antwort angezeigt wird.

Unabhängig von dieser Einstellung kann ein Scriptautor mit Bearbeitungszugriff auf das Formular mit der Methode FormResponse.getEditResponseUrl() eine URL generieren, mit der eine Antwort bearbeitet werden kann.

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

Rückflug

Boolean – true, wenn im Formular der Link „Antwort bearbeiten“ angezeigt wird; false, wenn dies nicht der Fall ist.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

collectsEmail()

Gibt an, ob im Formular die E‑Mail-Adressen der Umfrageteilnehmer erfasst werden.

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

Rückflug

Boolean – true, wenn im Formular E‑Mail-Adressen erfasst werden, false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

createResponse()

Erstellt eine neue Antwort auf das Formular. Um eine Frage zu beantworten, erstellen Sie ein ItemResponse aus dem Element und hängen Sie es an diese Antwort an, indem Sie FormResponse.withItemResponse(response) aufrufen. Rufen Sie FormResponse.submit() auf, um die zusammengestellte Antwort zu speichern.

Rückflug

FormResponse: Die neu erstellte Formularantwort.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

deleteAllResponses()

Löscht alle eingereichten Antworten aus dem Antwortspeicher des Formulars. Mit dieser Methode werden keine Kopien von Antworten gelöscht, die in einem externen Antwortziel (z. B. einer Tabelle) gespeichert sind. Die Zusammenfassungsansicht des Formulars wird jedoch geleert.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

deleteItem(index)

Löscht das Element an einem bestimmten Index unter allen Elementen im Formular. Löst eine Scripting-Ausnahme aus, wenn am angegebenen Index kein Element vorhanden ist.

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

NameTypBeschreibung
indexIntegerDer Index des Elements unter allen Elementen im Formular.

Löst

Error: Wenn am angegebenen Index kein Element vorhanden ist

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

deleteItem(item)

Löscht das angegebene Element. Löst eine Scripting-Ausnahme aus, wenn das Element bereits gelöscht wurde.

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

NameTypBeschreibung
itemItemDas zu löschende Element.

Löst

Error: wenn das Element im Formular nicht vorhanden ist

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

deleteResponse(responseId)

Löscht eine einzelne Antwort aus dem Antwortspeicher des Formulars. Mit dieser Methode werden keine Kopien von Antworten gelöscht, die an einem externen Zielort für Antworten (z. B. in einer Tabelle) gespeichert sind. Die Antwort wird jedoch aus der Übersicht des Formulars entfernt. Die Antwort-ID kann mit FormResponse.getId() abgerufen werden.

Parameter

NameTypBeschreibung
responseIdStringDie ID der zu löschenden Formularantwort.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getConfirmationMessage()

Ruft die Bestätigungsnachricht des Formulars ab.

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

Rückflug

String: Die Bestätigungsnachricht des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getCustomClosedFormMessage()

Ruft die benutzerdefinierte Nachricht ab, die angezeigt wird, wenn für das Formular keine Antworten angenommen werden, oder einen leeren String, wenn keine benutzerdefinierte Nachricht festgelegt ist.

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

Rückflug

String: Die benutzerdefinierte Nachricht, die angezeigt werden soll, wenn für das Formular keine Antworten mehr angenommen werden, oder ein leerer String, wenn keine benutzerdefinierte Nachricht festgelegt ist.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getDescription()

Ruft die Beschreibung des Formulars ab.

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

Rückflug

String: Die Beschreibung des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getDestinationId()

Ruft die ID des Antwortziels des Formulars ab.

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

Rückflug

String: Die ID des Antwortziels des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getDestinationType()

Gibt den Typ des Antwortziels des Formulars zurück.

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

Rückflug

DestinationType: Der Typ des Antwortziels des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getEditUrl()

Ruft die URL ab, über die auf den Bearbeitungsmodus des Formulars zugegriffen werden kann.

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

Rückflug

String: Die URL zum Bearbeiten des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getEditors()

Ruft die Liste der Mitbearbeiter für diese Form ab.

Rückflug

User[]: Ein Array von Nutzern mit Bearbeitungsberechtigung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getId()

Ruft die ID des Formulars ab.

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

Rückflug

String: Die ID des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getItemById(id)

Ruft das Element mit einer bestimmten ID ab. Gibt null zurück, wenn die ID keinem Element im Formular entspricht.

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

NameTypBeschreibung
idIntegerDie ID des Artikels.

Rückflug

Item|null: Das Element mit der angegebenen ID oder null, wenn das Element nicht im Formular vorhanden ist.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getItems()

Ruft ein Array aller Elemente im Formular ab.

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

Rückflug

Item[]: Ein Array mit allen Elementen im Formular.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getItems(itemType)

Ruft ein Array aller Elemente eines bestimmten Typs ab.

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

NameTypBeschreibung
itemTypeItemTypeDer Typ der abzurufenden Elemente.

Rückflug

Item[]: Ein Array aller Elemente dieses Typs.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getPublishedReaders()

Ruft die Liste der Antworten für diese Form ab.

// 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 responders for the form.
const users = form.getPublishedReaders();
users.forEach(user => console.log(user.getEmail()));

Rückflug

User[]: Ein Array von Nutzern mit der Berechtigung „Antworten“.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getPublishedUrl()

Gibt die URL zurück, die zum Beantworten des Formulars verwendet werden kann.

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

Rückflug

String: Die URL, über die das Formular ausgefüllt werden kann.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getResponse(responseId)

Ruft eine einzelne Formularantwort anhand ihrer Antwort-ID ab. Antwort-IDs können über FormResponse.getId() abgerufen werden.

Parameter

NameTypBeschreibung
responseIdStringDie ID der Formularantwort.

Rückflug

FormResponse: Die Formularantwort.

Löst

Error: wenn die Antwort nicht vorhanden ist

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getResponses()

Ruft ein Array mit allen Antworten des Formulars ab.

Rückflug

FormResponse[]: Ein Array mit allen Antworten des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getResponses(timestamp)

Ruft ein Array aller Antworten des Formulars nach einem bestimmten Datum und einer bestimmten Uhrzeit ab.

Parameter

NameTypBeschreibung
timestampDateDas früheste Datum und die früheste Uhrzeit, für die Formularantworten zurückgegeben werden sollen.

Rückflug

FormResponse[]: Die Liste der Formularantworten.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getShuffleQuestions()

Gibt an, ob die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig ist.

Rückflug

Boolean – true, wenn die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig ist; false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getSummaryUrl()

Ruft die URL ab, die zum Aufrufen einer Zusammenfassung der Antworten des Formulars verwendet werden kann. Sofern setPublishingSummary(enabled) nicht auf true festgelegt ist, können nur Nutzer mit Bearbeitungsberechtigung für das Formular auf die URL zugreifen.

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

Rückflug

String: Die URL, über die eine Zusammenfassung der Antworten aufgerufen werden kann.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

getTitle()

Ruft den Titel des Formulars ab.

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

Rückflug

String: Der Titel des Formulars.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

hasLimitOneResponsePerUser()

Gibt an, ob das Formular nur eine Antwort pro Antwortgeber zulässt. Wenn der Wert true ist, kann das Skript überhaupt keine Formularantworten senden.

Rückflug

Boolean – true, wenn für das Formular nur eine Antwort pro Befragtem zulässig ist; false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

hasProgressBar()

Legt fest, ob im Formular eine Fortschrittsanzeige zu sehen ist.

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

Rückflug

Boolean – true, wenn im Formular eine Fortschrittsanzeige zu sehen ist, false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

Bestimmt, ob im Formular ein Link zum Senden einer weiteren Antwort angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat.

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

Rückflug

Boolean – true, wenn im Formular der Link „Weitere Antwort senden“ angezeigt wird; false, wenn dies nicht der Fall ist.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

isAcceptingResponses()

Gibt an, ob für das Formular derzeit Antworten angenommen werden. Dieser Wert wird überschrieben, wenn sich der Veröffentlichungsstatus des Formulars ändert.

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

Rückflug

Boolean – true, wenn für das Formular Antworten angenommen werden, false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

isPublished()

Gibt an, ob das Formular veröffentlicht wird.

Diese Funktion ist nur für Formulare verfügbar, die die Veröffentlichung unterstützen. Verwenden Sie supportsAdvancedResponderPermissions(), um zu prüfen, ob das Formular die Veröffentlichung unterstützt.

// 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 whether the form is published or not and logs it to the console.
console.log(form.isPublished());

Rückflug

Boolean – true, wenn das Formular veröffentlicht ist, false, wenn nicht.

Löst

Error – wenn die Funktion für nicht unterstützte Formulare aufgerufen wird.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

isPublishingSummary()

Gibt an, ob im Formular ein Link zum Aufrufen einer Zusammenfassung der Antworten angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat.

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

Rückflug

Boolean – true, wenn im Formular der Link „Vorherige Antworten ansehen“ angezeigt wird; false, wenn dies nicht der Fall ist.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

isQuiz()

Gibt an, ob es sich bei dem Formular um ein Quiz handelt.

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

Rückflug

Boolean – true, wenn für das Formular Antworten angenommen werden, false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

moveItem(from, to)

Verschiebt ein Element an einem bestimmten Index unter allen Elementen im Formular an einen anderen bestimmten Index. Löst eine Scripting-Ausnahme aus, wenn der to-Index außerhalb des zulässigen Bereichs liegt.

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

NameTypBeschreibung
fromIntegerDer aktuelle Index des Elements unter allen Elementen im Formular.
toIntegerDer neue Index für das Element unter allen Elementen im Formular.

Rückflug

Item: Das Element, das verschoben wurde.

Löst

Error: wenn einer der beiden Indexe außerhalb des zulässigen Bereichs liegt.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

moveItem(item, toIndex)

Verschiebt ein bestimmtes Element an einen bestimmten Index unter allen Elementen im Formular. Löst eine Scripting-Ausnahme aus, wenn der angegebene Index außerhalb des zulässigen Bereichs liegt.

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

NameTypBeschreibung
itemItemDas zu verschiebende Element.
toIndexIntegerDer neue Index für das Element unter allen Elementen im Formular.

Rückflug

Item: Das Element, das verschoben wurde.

Löst

Error: wenn der Index außerhalb des zulässigen Bereichs liegt.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

removeDestination()

Hebt die Verknüpfung des Formulars mit dem aktuellen Antwortziel auf. Das nicht verknüpfte frühere Ziel behält weiterhin eine Kopie aller vorherigen Antworten. Für alle Formulare, auch für solche, für die kein Ziel explizit festgelegt ist, wird eine Kopie der Antworten im Antwortspeicher des Formulars gespeichert. Wenn für das Formular derzeit kein Antwortziel festgelegt ist, hat diese Methode keine Auswirkungen.

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

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

removeEditor(emailAddress)

Entfernt den angegebenen Nutzer aus der Liste der Mitbearbeiter für die Form. Mit dieser Methode wird der Zugriff von Nutzern auf die Form nicht blockiert, wenn sie zu einer Nutzerklasse gehören, die allgemeinen Zugriff hat. Das ist beispielsweise der Fall, wenn die Form für die gesamte Domain des Nutzers freigegeben ist oder sich die Form in einer geteilten Ablage befindet, auf die der Nutzer zugreifen kann.

Bei Drive-Dateien wird der Nutzer dadurch auch aus der Liste der Betrachter und Antwortenden entfernt.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Removes the editor from the form.
// TODO(developer): replace the emailAddress.
form.removeEditor('editor@uni.edu');

Parameter

NameTypBeschreibung
emailAddressStringDie E‑Mail-Adresse des Nutzers, der entfernt werden soll.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

removeEditor(user)

Entfernt den angegebenen Nutzer aus der Liste der Mitbearbeiter für die Form. Mit dieser Methode wird der Zugriff von Nutzern auf die Form nicht blockiert, wenn sie zu einer Nutzerklasse gehören, die allgemeinen Zugriff hat. Das ist beispielsweise der Fall, wenn die Form für die gesamte Domain des Nutzers freigegeben ist oder sich die Form in einer geteilten Ablage befindet, auf die der Nutzer zugreifen kann.

Bei Drive-Dateien wird der Nutzer dadurch auch aus der Liste der Betrachter entfernt.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the editors from the form.
const users = form1.getEditors();

// Opens another form.
// TODO(developer): Replace the URL with your own.
const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');

// Removes editors from the form.
users.forEach(user => form2.removeEditor(user));

Parameter

NameTypBeschreibung
userUserEine Darstellung des zu entfernenden Nutzers.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

removePublishedReader(emailAddress)

Entfernt den angegebenen Nutzer aus der Liste der Antwortenden für die Form. Mit dieser Methode wird der Zugriff auf die Form nicht für Nutzer blockiert, die einer Nutzerklasse mit allgemeinem Zugriff angehören, z. B. wenn die Form für die gesamte Domain des Nutzers freigegeben ist oder sich die Form in einer geteilten Ablage befindet, auf die der Nutzer zugreifen kann.

Bei Drive-Dateien wird der Nutzer dadurch auch aus der Liste der Betrachter und Mitbearbeiter entfernt.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Removes the responders from the form.
// TODO(developer): replace the emailAddress.
form.removePublishedReader('responder1@uni.edu');

Parameter

NameTypBeschreibung
emailAddressStringDie E‑Mail-Adresse des Nutzers, der entfernt werden soll.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

removePublishedReader(user)

Entfernt den angegebenen Nutzer aus der Liste der Antwortenden für die Form. Mit dieser Methode wird der Zugriff auf die Form nicht für Nutzer blockiert, die einer Nutzerklasse mit allgemeinem Zugriff angehören, z. B. wenn die Form für die gesamte Domain des Nutzers freigegeben ist oder sich die Form in einer geteilten Ablage befindet, auf die der Nutzer zugreifen kann.

Bei Drive-Dateien wird der Nutzer dadurch auch aus der Liste der Betrachter und Mitbearbeiter entfernt.

// Opens the Forms file by its URL.
// TODO(developer): Replace the URL with your own.
const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit');

// Gets the responders from the form.
const users = form1.getPublishedReaders();

// Opens another form.
// TODO(developer): Replace the URL with your own.
const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit');

// Removes responders from the form.
users.forEach(user => form2.removePublishedReader(user));

Parameter

NameTypBeschreibung
userUserEine Darstellung des zu entfernenden Nutzers.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setAcceptingResponses(enabled)

Legt fest, ob für das Formular derzeit Antworten angenommen werden. Der Standardwert für neue Formulare ist true. Der Status wird überschrieben, wenn sich der Veröffentlichungsstatus des Formulars ändert.

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

NameTypBeschreibung
enabledBooleantrue, wenn für das Formular Antworten angenommen werden sollen, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Löst

Error – wenn für ein nicht veröffentlichtes Formular aktiviert.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setAllowResponseEdits(enabled)

Legt fest, ob im Formular nach dem Senden einer Antwort ein Link zum Bearbeiten der Antwort angezeigt wird. Der Standardwert für neue Formulare ist false.

Unabhängig von dieser Einstellung kann ein Skriptautor mit Bearbeitungsberechtigung für das Formular mit der Methode FormResponse.getEditResponseUrl() eine URL generieren, mit der eine Antwort bearbeitet werden kann.

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

NameTypBeschreibung
enabledBooleantrue, wenn im Formular der Link „Antwort bearbeiten“ angezeigt werden soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setCollectEmail(collect)

Legt fest, ob im Formular die E‑Mail-Adressen der Umfrageteilnehmer erfasst werden. Der Standardwert für neue Formulare ist 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

NameTypBeschreibung
collectBooleantrue, wenn im Formular E‑Mail-Adressen erfasst werden sollen, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setConfirmationMessage(message)

Legt die Bestätigungsnachricht des Formulars fest.

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

NameTypBeschreibung
messageStringDie neue Bestätigungsnachricht des Formulars.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setCustomClosedFormMessage(message)

Legt die Meldung fest, die angezeigt werden soll, wenn für das Formular keine Antworten akzeptiert werden. Wenn keine Nachricht festgelegt ist, wird im Formular eine Standardnachricht verwendet.

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

NameTypBeschreibung
messageStringDie Meldung, die angezeigt werden soll, wenn für das Formular keine Antworten angenommen werden.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setDescription(description)

Legt die Beschreibung des Formulars fest.

Parameter

NameTypBeschreibung
descriptionStringDie neue Beschreibung des Formulars.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setDestination(type, id)

Legt das Ziel fest, in dem Formularantworten gespeichert werden. Für alle Formulare, auch für solche, für die kein Ziel explizit festgelegt ist, wird eine Kopie der Antworten im Antwortspeicher des Formulars gespeichert.

Parameter

NameTypBeschreibung
typeDestinationTypeDer Typ des Antwortziels des Formulars.
idStringDie ID des Antwortziels des Formulars.

Rückflug

Form – Diese Form zur Verkettung.

Löst

Error: Die angegebene Ziel-ID ist ungültig.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setIsQuiz(enabled)

Legt fest, ob das Formular ein Quiz ist. Der Standardwert für neue Formulare ist false.

Bewertete Fragen sind nur in Quizzen zulässig. Wenn Sie diese Option auf false setzen, werden alle Bewertungsoptionen aus allen Fragen entfernt.

Quiz-Einstellungen sind nur in der neuen Google Formulare-Benutzeroberfläche verfügbar. Wenn Sie ein Formular in ein Quiz umwandeln, wird die neue Benutzeroberfläche für das Formular verwendet.

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

NameTypBeschreibung
enabledBooleantrue, wenn die Quizfunktionen für das Formular aktiviert werden sollen, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setLimitOneResponsePerUser(enabled)

Legt fest, ob das Formular nur eine Antwort pro Teilnehmer zulässt. Der Standardwert für neue Formulare ist false. Wenn der Wert auf true gesetzt ist, kann das Skript überhaupt keine Formularantworten senden.

Parameter

NameTypBeschreibung
enabledBooleantrue, wenn für das Formular nur eine Antwort pro Teilnehmer zulässig sein soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setProgressBar(enabled)

Legt fest, ob das Formular eine Fortschrittsanzeige hat. Der Standardwert für neue Formulare ist 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

NameTypBeschreibung
enabledBooleantrue, wenn im Formular eine Fortschrittsanzeige zu sehen ist, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setPublished(enabled)

Legt fest, ob das Formular veröffentlicht wird. Der Standardwert für neue Formulare ist true.

Diese Funktion ist nur für Formulare verfügbar, die die Veröffentlichung unterstützen. Verwenden Sie supportsAdvancedResponderPermissions(), um zu prüfen, ob das Formular die Veröffentlichung unterstützt.

Ein Formular muss veröffentlicht werden, damit es für Teilnehmer zugänglich ist. Diese Methode ersetzt Aufrufe von setAcceptingResponses(enabled).

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

// Publishes the form before sharing it.
form.setPublished(true);

// Checks whether the form is published or not and logs it to the console.
console.log(form.isPublished());

Parameter

NameTypBeschreibung
enabledBooleantrue, wenn das Formular veröffentlicht werden soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Löst

Error – wenn die Funktion für nicht unterstützte Formulare aufgerufen wird.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setPublishingSummary(enabled)

Legt fest, ob im Formular ein Link zum Anzeigen einer Zusammenfassung der Antworten angezeigt wird, nachdem ein Teilnehmer das Formular gesendet hat. Der Standardwert für neue Formulare ist false.

Parameter

NameTypBeschreibung
enabledBooleantrue, wenn im Formular der Link „Vorherige Antworten ansehen“ angezeigt werden soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setShowLinkToRespondAgain(enabled)

Legt fest, ob im Formular ein Link zum Senden einer weiteren Antwort angezeigt wird, nachdem ein Teilnehmer das Formular ausgefüllt hat. Der Standardwert für neue Formulare ist true.

Parameter

NameTypBeschreibung
enabledBooleantrue, wenn im Formular der Link „Weitere Antwort senden“ angezeigt werden soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setShuffleQuestions(shuffle)

Legt fest, ob die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig ist.

Parameter

NameTypBeschreibung
shuffleBooleantrue, wenn die Reihenfolge der Fragen auf jeder Seite des Formulars zufällig sein soll, false, wenn nicht.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

setTitle(title)

Legt den Titel des Formulars fest.

Parameter

NameTypBeschreibung
titleStringDer neue Titel des Formulars.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

shortenFormUrl(url)

Wandelt eine lange URL für ein Formular in eine kurze URL um. Löst eine Ausnahme aus, wenn die lange URL nicht zu Google Formulare gehört.

Parameter

NameTypBeschreibung
urlStringDie zu verkürzende URL.

Rückflug

String: Eine URL im Format http://goo.gl/forms/1234.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

submitGrades(responses)

Reicht Noten für die angegebenen FormResponses ein.

Wenn Ihr Code einen onFormSubmit-Trigger enthält, wird durch den Aufruf von submitGrades() die onFormSubmit-Bedingung ausgelöst und es kommt zu einer Endlosschleife. Fügen Sie Code hinzu, der prüft, ob Noten bereits vorhanden sind, bevor Sie submitGrades() aufrufen, um die Endlosschleife zu verhindern.

Parameter

NameTypBeschreibung
responsesFormResponse[]Ein Array mit allen Antworten des Formulars.

Rückflug

Form – Diese Form zur Verkettung.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

supportsAdvancedResponderPermissions()

Gibt an, ob das Formular die Veröffentlichung unterstützt. Mit dieser Methode wird ermittelt, ob die Methoden setPublished(enabled) und isPublished() sowie die Berechtigungen für Antwortende verfügbar sind.

// 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 whether the form supports publishing or not and logs it to the
// console.
console.log(form.supportsAdvancedResponderPermissions());

Rückflug

Boolean – true, wenn das Formular die Veröffentlichung unterstützt, false, wenn nicht.

Autorisierung

Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:

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

Eingestellte Methoden