Class Form

טופס

טופס שמכיל מאפיינים ופריטים כלליים. המאפיינים כוללים את השם, ההגדרות והמקום שבו התשובות מאוחסנות. הפריטים כוללים פריטי שאלות כמו תיבות סימון או פריטי בחירה, בעוד שפריטי פריסה מתייחסים לדברים כמו מעברי דפים. אפשר לגשת לטפסים או ליצור אותם מ-FormApp.

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

Methods

שיטהסוג הערך שמוחזרתיאור קצר
addCheckboxGridItem()CheckboxGridItemהפונקציה מוסיפה פריט שאלה חדש, שמוצג כרשת של עמודות ושורות, ומאפשרת למשיב לבחור כמה תשובות לכל שורה מתוך רצף של תיבות סימון.
addCheckboxItem()CheckboxItemמוסיף פריט שאלה חדש שמאפשר למשיב לסמן תיבת סימון אחת או יותר, וגם שדה אופציונלי של "אחר".
addDateItem()DateItemמוסיפה פריט חדש של שאלה שמאפשר למשיב לציין תאריך.
addDateTimeItem()DateTimeItemמוסיפה פריט שאלה חדש שמאפשר למשיב לציין תאריך ושעה.
addDurationItem()DurationItemמוסיפה פריט שאלה חדש שמאפשר למשיב לציין משך זמן.
addEditor(emailAddress)Formהוספת המשתמש שצוין לרשימת העורכים של Form.
addEditor(user)Formהוספת המשתמש שצוין לרשימת העורכים של Form.
addEditors(emailAddresses)Formמוסיף את מערך המשתמשים שצוין לרשימת בעלי הרשאת העריכה של Form.
addGridItem()GridItemהפונקציה מוסיפה פריט שאלה חדש, שמוצג כרשת של עמודות ושורות, ומאפשרת למשיב לבחור אפשרות אחת לכל שורה מתוך רצף של כפתורי בחירה.
addImageItem()ImageItemמוסיף פריט פריסה חדש שמציג תמונה.
addListItem()ListItemמוסיף פריט שאלה חדש שמאפשר למשיב לבחור אפשרות אחת מתוך רשימה נפתחת.
addMultipleChoiceItem()MultipleChoiceItemמוסיף פריט שאלה חדש שמאפשר למשיב לבחור תשובה אחת מתוך רשימה של לחצני בחירה או שדה אופציונלי של 'אחר'.
addPageBreakItem()PageBreakItemמוסיף פריט פריסה חדש שמסמן את תחילת הדף.
addParagraphTextItem()ParagraphTextItemהוספת פריט שאלה חדש שמאפשר למשיב להזין בלוק טקסט.
addPublishedReader(emailAddress)Formהפעולה הזו מוסיפה את המשתמש שצוין לרשימת המשיבים של Form.
addPublishedReader(user)Formהפעולה הזו מוסיפה את המשתמש שצוין לרשימת המשיבים של Form.
addPublishedReaders(emailAddresses)Formהפונקציה מוסיפה את מערך המשתמשים שצוין לרשימת המשיבים של Form.
addRatingItem()RatingItemמוסיפה פריט שאלה חדש שמאפשר למשיב לתת דירוג.
addScaleItem()ScaleItemמוסיפה פריט שאלה חדש שמאפשר למשיב לבחור אפשרות אחת מתוך רצף ממוספר של לחצני בחירה.
addSectionHeaderItem()SectionHeaderItemמוסיף פריט פריסה חדש שמציין חזותית את תחילת הקטע.
addTextItem()TextItemמוסיפה פריט שאלה חדש שמאפשר למשיב להזין שורה אחת של טקסט.
addTimeItem()TimeItemמוסיפה פריט חדש של שאלה שמאפשרת למשיב לציין שעה ביום.
addVideoItem()VideoItemמוסיף פריט פריסה חדש שמציג סרטון.
canEditResponse()Booleanקובעת אם בטופס יוצג קישור לעריכת תשובה אחרי שליחתה.
collectsEmail()Booleanהגדרה שקובעת אם הטופס יאסוף את כתובות האימייל של המשיבים.
createResponse()FormResponseיצירת תשובה חדשה לטופס.
deleteAllResponses()Formמחיקת כל התגובות שנשלחו ממאגר התגובות של הטופס.
deleteItem(index)voidמוחק את הפריט באינדקס נתון מבין כל הפריטים בטופס.
deleteItem(item)voidמחיקת הפריט שצוין.
deleteResponse(responseId)Formמחיקת תגובה אחת ממאגר התגובות של הטופס.
getConfirmationMessage()Stringמקבל את הודעת האישור של הטופס.
getCustomClosedFormMessage()Stringמחזירה את ההודעה המותאמת אישית שמוצגת אם הטופס לא מקבל תשובות, או מחזירה מחרוזת ריקה אם לא מוגדרת הודעה מותאמת אישית.
getDescription()Stringמחזירה את תיאור הטופס.
getDestinationId()Stringמחזירה את המזהה של יעד התשובות של הטופס.
getDestinationType()DestinationTypeמחזירה את סוג היעד של התשובות בטופס.
getEditUrl()Stringמחזירה את כתובת ה-URL שאפשר להשתמש בה כדי לגשת למצב העריכה של הטופס.
getEditors()User[]מחזירה את רשימת העורכים של ה-Form הזה.
getId()Stringמקבל את המזהה של הטופס.
getItemById(id)Item|nullמקבל את הפריט עם המזהה הנתון.
getItems()Item[]מחזירה מערך של כל הפריטים בטופס.
getItems(itemType)Item[]הפונקציה מחזירה מערך של כל הפריטים מסוג מסוים.
getPublishedReaders()User[]מחזירה את רשימת המשיבים של ה-Form הזה.
getPublishedUrl()Stringמחזירה את כתובת ה-URL שאפשר להשתמש בה כדי להשיב על הטופס.
getResponse(responseId)FormResponseמקבל תשובה אחת לטופס על סמך מזהה התשובה.
getResponses()FormResponse[]מחזירה מערך של כל התשובות בטופס.
getResponses(timestamp)FormResponse[]מחזירה מערך של כל התגובות בטופס אחרי תאריך ושעה מסוימים.
getShuffleQuestions()Booleanקובע אם סדר השאלות בכל דף בטופס הוא אקראי.
getSummaryUrl()Stringמחזירה את כתובת ה-URL שאפשר להשתמש בה כדי לראות סיכום של התשובות בטופס.
getTitle()Stringהפונקציה מחזירה את הכותרת של הטופס.
hasLimitOneResponsePerUser()Booleanקובעת אם כל משיב יכול לשלוח רק תשובה אחת לטופס.
hasProgressBar()Booleanקובעת אם יוצג סרגל התקדמות בטופס.
hasRespondAgainLink()Booleanההגדרה קובעת אם יוצג בטופס קישור לשליחת תשובה נוספת אחרי שמשיב משלים את הטופס.
isAcceptingResponses()Booleanקובעת אם הטופס מקבל כרגע תשובות.
isPublished()Booleanקובעת אם הטופס פורסם.
isPublishingSummary()Booleanקובעת אם בטופס יוצג קישור לצפייה בסיכום התשובות אחרי שהמשיב יסיים למלא את הטופס.
isQuiz()Booleanקובעת אם הטופס הוא בוחן.
moveItem(from, to)Itemהפונקציה מעבירה פריט באינדקס נתון בין כל הפריטים בטופס לאינדקס נתון אחר.
moveItem(item, toIndex)Itemמעביר פריט נתון לאינדקס נתון מבין כל הפריטים בטופס.
removeDestination()Formביטול הקישור של הטופס ליעד התשובות הנוכחי שלו.
removeEditor(emailAddress)Formמסיר את המשתמש שצוין מרשימת העורכים של Form.
removeEditor(user)Formמסיר את המשתמש שצוין מרשימת העורכים של Form.
removePublishedReader(emailAddress)Formמסירה את המשתמש שצוין מרשימת המשיבים של Form.
removePublishedReader(user)Formמסירה את המשתמש שצוין מרשימת המשיבים של Form.
setAcceptingResponses(enabled)Formהגדרה של קבלת תשובות לטופס.
setAllowResponseEdits(enabled)Formהגדרה של הצגת קישור לעריכת תשובה בטופס אחרי שליחתה.
setCollectEmail(collect)Formהגדרה של איסוף כתובות האימייל של המשיבים בטופס.
setConfirmationMessage(message)Formהגדרת הודעת האישור של הטופס.
setCustomClosedFormMessage(message)Formהגדרת ההודעה שתוצג אם הטופס לא מקבל תשובות.
setDescription(description)Formהגדרת התיאור של הטופס.
setDestination(type, id)Formההגדרה הזו קובעת את היעד שבו נשמרות התשובות לטופס.
setIsQuiz(enabled)Formהגדרה אם הטופס הוא בוחן.
setLimitOneResponsePerUser(enabled)Formהגדרה של האפשרות שכל משיב יוכל לשלוח רק תשובה אחת לטופס.
setProgressBar(enabled)Formקובע אם בטופס יוצג סרגל התקדמות.
setPublished(enabled)Formקובעת אם הטופס פורסם.
setPublishingSummary(enabled)Formקובעת אם בטופס יוצג קישור לצפייה בסיכום התשובות אחרי שהמשיב ישלח את הטופס.
setShowLinkToRespondAgain(enabled)Formההגדרה הזו קובעת אם יוצג בטופס קישור לשליחת תגובה נוספת אחרי שהמשיב מסיים למלא את הטופס.
setShuffleQuestions(shuffle)Formהגדרה של סדר אקראי לשאלות בכל דף בטופס.
setTitle(title)Formהגדרת הכותרת של הטופס.
shortenFormUrl(url)Stringממירה כתובת URL ארוכה של טופס לכתובת URL קצרה.
submitGrades(responses)Formשליחת ציונים עבור תשובות ספציפיות בטופס.
supportsAdvancedResponderPermissions()Booleanקובעת אם הטופס תומך בפרסום.

תיעוד מפורט

addCheckboxGridItem()

הפונקציה מוסיפה פריט שאלה חדש, שמוצג כרשת של עמודות ושורות, ומאפשרת למשיב לבחור כמה תשובות לכל שורה מתוך רצף של תיבות סימון.

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

חזרה

CheckboxGridItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addCheckboxItem()

מוסיף פריט שאלה חדש שמאפשר למשיב לסמן תיבת סימון אחת או יותר, וגם שדה אופציונלי של "אחר".

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

חזרה

CheckboxItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addDateItem()

מוסיפה פריט חדש של שאלה שמאפשר למשיב לציין תאריך.

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

חזרה

DateItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addDateTimeItem()

מוסיפה פריט שאלה חדש שמאפשר למשיב לציין תאריך ושעה.

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

חזרה

DateTimeItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addDurationItem()

מוסיפה פריט שאלה חדש שמאפשר למשיב לציין משך זמן.

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

חזרה

DurationItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addEditor(emailAddress)

הוספת המשתמש שצוין לרשימת העורכים של Form. אם המשתמש כבר היה ברשימת הצופים או המשיבים, השיטה הזו תוציא אותו מהרשימה.

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

פרמטרים

שםסוגתיאור
emailAddressStringכתובת האימייל של המשתמש שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addEditor(user)

הוספת המשתמש שצוין לרשימת העורכים של Form. אם המשתמש כבר היה ברשימת הצופים או המשיבים, השיטה הזו תוציא אותו מהרשימה.

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

פרמטרים

שםסוגתיאור
userUserייצוג של המשתמש שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addEditors(emailAddresses)

מוסיף את מערך המשתמשים שצוין לרשימת בעלי הרשאת העריכה של Form. אם חלק מהמשתמשים כבר היו ברשימת הצופים, השיטה הזו תסיר אותם מרשימת הצופים.

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

פרמטרים

שםסוגתיאור
emailAddressesString[]מערך של כתובות אימייל של המשתמשים שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addGridItem()

הפונקציה מוסיפה פריט שאלה חדש, שמוצג כרשת של עמודות ושורות, ומאפשרת למשיב לבחור אפשרות אחת לכל שורה מתוך רצף של כפתורי בחירה.

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

חזרה

GridItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addImageItem()

מוסיף פריט פריסה חדש שמציג תמונה.

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

חזרה

ImageItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addListItem()

מוסיף פריט שאלה חדש שמאפשר למשיב לבחור אפשרות אחת מתוך רשימה נפתחת.

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

חזרה

ListItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addMultipleChoiceItem()

מוסיף פריט שאלה חדש שמאפשר למשיב לבחור תשובה אחת מתוך רשימה של לחצני בחירה או שדה אופציונלי של 'אחר'.

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

חזרה

MultipleChoiceItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addPageBreakItem()

מוסיף פריט פריסה חדש שמסמן את תחילת הדף.

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

חזרה

PageBreakItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addParagraphTextItem()

הוספת פריט שאלה חדש שמאפשר למשיב להזין בלוק טקסט.

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

חזרה

ParagraphTextItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addPublishedReader(emailAddress)

הפעולה הזו מוסיפה את המשתמש שצוין לרשימת המשיבים של Form. אם המשתמש כבר היה ברשימת העורכים או הצופים, לשיטה הזו אין השפעה.

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

פרמטרים

שםסוגתיאור
emailAddressStringכתובת האימייל של המשתמש שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addPublishedReader(user)

הפעולה הזו מוסיפה את המשתמש שצוין לרשימת המשיבים של Form. אם המשתמש כבר היה ברשימת העורכים או הצופים, לשיטה הזו אין השפעה.

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

פרמטרים

שםסוגתיאור
userUserייצוג של המשתמש שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addPublishedReaders(emailAddresses)

הפונקציה מוסיפה את מערך המשתמשים שצוין לרשימת המשיבים של Form. אם המשתמש כבר נמצא ברשימת העורכים או הצופים, לשיטה הזו אין השפעה.

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

פרמטרים

שםסוגתיאור
emailAddressesString[]מערך של כתובות אימייל של המשתמשים שרוצים להוסיף.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addRatingItem()

מוסיפה פריט שאלה חדש שמאפשר למשיב לתת דירוג.

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

חזרה

RatingItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addScaleItem()

מוסיפה פריט שאלה חדש שמאפשר למשיב לבחור אפשרות אחת מתוך רצף ממוספר של לחצני בחירה.

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

חזרה

ScaleItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addSectionHeaderItem()

מוסיף פריט פריסה חדש שמציין חזותית את תחילת הקטע.

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

חזרה

SectionHeaderItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addTextItem()

מוסיפה פריט שאלה חדש שמאפשר למשיב להזין שורה אחת של טקסט.

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

חזרה

TextItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addTimeItem()

מוסיפה פריט חדש של שאלה שמאפשר למשיב לציין שעה ביום.

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

חזרה

TimeItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

addVideoItem()

מוסיף פריט פריסה חדש שמציג סרטון.

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

חזרה

VideoItem – הפריט שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

canEditResponse()

קובעת אם בטופס יוצג קישור לעריכת תשובה אחרי שליחתה.

ללא קשר להגדרה הזו, השיטה FormResponse.getEditResponseUrl() מאפשרת ליוצר הסקריפט שיש לו גישת עריכה לטופס ליצור כתובת URL שאפשר להשתמש בה כדי לערוך תשובה.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// 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);

חזרה

Booleantrue אם בטופס מופיע הקישור 'עריכת התשובה שלך'; false אם הוא לא מופיע.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

collectsEmail()

קובעת אם הטופס יאסוף את כתובות האימייל של המשיבים.

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

חזרה

Booleantrue אם הטופס אוסף כתובות אימייל, false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

createResponse()

יצירת תשובה חדשה לטופס. כדי להשיב לשאלה, יוצרים ItemResponse מהשאלה ומצרפים אותה לתשובה לטופס באמצעות הקריאה FormResponse.withItemResponse(response). כדי לשמור את התשובה המורכבת, מתקשרים אל FormResponse.submit().

חזרה

FormResponse — התשובה החדשה לטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

deleteAllResponses()

מחיקת כל התגובות שנשלחו ממאגר התגובות של הטופס. השיטה הזו לא מוחקת עותקים של תשובות ששמורים ביעד חיצוני לתשובות (כמו גיליון אלקטרוני), אבל היא מוחקת את תצוגת הסיכום של הטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

deleteItem(index)

מוחק את הפריט באינדקס נתון מבין כל הפריטים בטופס. הפונקציה זורקת חריגה של סקריפטים אם לא קיים פריט באינדקס הנתון.

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

פרמטרים

שםסוגתיאור
indexIntegerהאינדקס של הפריט מבין כל הפריטים בטופס.

מקפיצה את הודעות השגיאה (Throws)

Error – אם לא קיים פריט באינדקס הנתון

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

deleteItem(item)

מחיקת הפריט שצוין. אם הפריט כבר נמחק, הפונקציה מחזירה חריגה של סקריפט.

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

פרמטרים

שםסוגתיאור
itemItemהפריט שרוצים למחוק.

מקפיצה את הודעות השגיאה (Throws)

Error – אם הפריט לא קיים בטופס

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

deleteResponse(responseId)

מחיקת תגובה אחת ממאגר התגובות של הטופס. השיטה הזו לא מוחקת עותקים של תשובות ששמורים ביעד חיצוני (כמו גיליון אלקטרוני), אבל היא מסירה את התשובה מתצוגת הסיכום של הטופס. אפשר לאחזר את מזהה התשובה באמצעות FormResponse.getId().

פרמטרים

שםסוגתיאור
responseIdStringהמזהה של התשובה לטופס שרוצים למחוק.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getConfirmationMessage()

מקבל את הודעת האישור של הטופס.

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

חזרה

String — הודעת האישור של הטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getCustomClosedFormMessage()

מחזירה את ההודעה המותאמת אישית שמוצגת אם הטופס לא מקבל תשובות, או מחזירה מחרוזת ריקה אם לא מוגדרת הודעה מותאמת אישית.

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

חזרה

String — ההודעה המותאמת אישית שתוצג אם הטופס לא מקבל תשובות, או מחרוזת ריקה אם לא הוגדרה הודעה מותאמת אישית.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getDescription()

מחזירה את תיאור הטופס.

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

חזרה

String – תיאור הטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getDestinationId()

מחזירה את המזהה של יעד התשובות של הטופס.

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

חזרה

String – המזהה של יעד התשובות בטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getDestinationType()

מחזירה את סוג היעד של התשובות לטופס.

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

חזרה

DestinationType – הסוג של יעד התשובות בטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getEditUrl()

מחזירה את כתובת ה-URL שאפשר להשתמש בה כדי לגשת למצב העריכה של הטופס.

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

חזרה

String — כתובת ה-URL לעריכת הטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getEditors()

מחזירה את רשימת העורכים של ה-Form הזה.

חזרה

User[] — מערך של משתמשים עם הרשאת עריכה.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getId()

מקבל את המזהה של הטופס.

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

חזרה

String – המזהה של הטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getItemById(id)

מקבל את הפריט עם המזהה הנתון. הפונקציה מחזירה null אם המזהה לא תואם לפריט בטופס.

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

פרמטרים

שםסוגתיאור
idIntegerהמזהה של הפריט.

חזרה

Item|null – הפריט עם המזהה שצוין, או null אם הפריט לא קיים בטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getItems()

מחזירה מערך של כל הפריטים בטופס.

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

חזרה

Item[] – מערך של כל הפריטים בטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getItems(itemType)

הפונקציה מחזירה מערך של כל הפריטים מסוג מסוים.

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

פרמטרים

שםסוגתיאור
itemTypeItemTypeסוג הפריטים לאחזור.

חזרה

Item[] – מערך של כל הפריטים מהסוג הזה.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getPublishedReaders()

מחזירה את רשימת המשיבים של ה-Form הזה.

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

חזרה

User[] — מערך של משתמשים עם הרשאת מענה.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getPublishedUrl()

מחזירה את כתובת ה-URL שאפשר להשתמש בה כדי להשיב על הטופס.

// Opens the Forms file by its URL. If you created your script from within
// a Google Forms file, you can use FormApp.getActiveForm() instead.
// 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);

חזרה

String – כתובת ה-URL להגשת תשובות לטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getResponse(responseId)

מקבל תשובה אחת לטופס על סמך מזהה התשובה. אפשר לאחזר את מזהי התשובות מ-FormResponse.getId().

פרמטרים

שםסוגתיאור
responseIdStringהמזהה של התשובה לטופס.

חזרה

FormResponse — התשובה לטופס.

מקפיצה את הודעות השגיאה (Throws)

Error – אם התשובה לא קיימת

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getResponses()

מחזירה מערך של כל התשובות בטופס.

חזרה

FormResponse[] – מערך של כל התגובות בטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getResponses(timestamp)

מחזירה מערך של כל התגובות בטופס אחרי תאריך ושעה מסוימים.

פרמטרים

שםסוגתיאור
timestampDateהתאריך והשעה המוקדמים ביותר שבהם צריך להחזיר תשובות לטופס.

חזרה

FormResponse[] — רשימת התשובות לטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getShuffleQuestions()

קובע אם סדר השאלות בכל דף בטופס הוא אקראי.

חזרה

Booleantrue אם סדר השאלות בכל דף בטופס הוא אקראי; false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getSummaryUrl()

מחזירה את כתובת ה-URL שאפשר להשתמש בה כדי לראות סיכום של התשובות בטופס. אלא אם ההגדרה setPublishingSummary(enabled) מוגדרת כ-true, רק למשתמשים עם הרשאת עריכה בטופס יש גישה לכתובת ה-URL.

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

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

חזרה

String – כתובת ה-URL להצגת סיכום של התשובות.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

getTitle()

הפונקציה מחזירה את הכותרת של הטופס.

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

חזרה

String – הכותרת של הטופס.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

hasLimitOneResponsePerUser()

קובעת אם כל משיב יכול לשלוח רק תשובה אחת לטופס. אם הערך הוא true, הסקריפט לא יכול לשלוח תגובות לטופס בכלל.

חזרה

Booleantrue אם הטופס מאפשר רק תשובה אחת לכל משיב, false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

hasProgressBar()

קובעת אם יוצג סרגל התקדמות בטופס.

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

חזרה

Booleantrue אם מוצג סרגל התקדמות בטופס; false אם לא מוצג סרגל התקדמות.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

ההגדרה קובעת אם יוצג בטופס קישור לשליחת תשובה נוספת אחרי שמשיב משלים את הטופס.

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

חזרה

Booleantrue אם בטופס מופיע הקישור 'שליחת תגובה נוספת'; false אם הוא לא מופיע.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

isAcceptingResponses()

קובעת אם הטופס מקבל כרגע תשובות. הערך הזה נדרס כשמצב הפרסום של הטופס משתנה.

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

חזרה

Booleantrue אם אפשר לשלוח תשובות לטופס; false אם אי אפשר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

isPublished()

קובעת אם הטופס פורסם.

התכונה הזו זמינה רק בטפסים שתומכים בפרסום. משתמשים בלחצן supportsAdvancedResponderPermissions() כדי לבדוק אם הטופס תומך בפרסום.

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

חזרה

Booleantrue אם הטופס פורסם; false אם הוא לא פורסם.

מקפיצה את הודעות השגיאה (Throws)

Error – אם מתקשרים באמצעות טפסים שלא נתמכים.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

isPublishingSummary()

קובעת אם בטופס יוצג קישור לצפייה בסיכום התשובות אחרי שהמשיב יסיים למלא את הטופס.

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

חזרה

Booleantrue אם בטופס מוצג הקישור 'לצפייה בתשובות הקודמות'; false אם הוא לא מוצג.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

isQuiz()

קובעת אם הטופס הוא בוחן.

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

חזרה

Booleantrue אם אפשר לשלוח תשובות לטופס; false אם אי אפשר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

moveItem(from, to)

הפונקציה מעבירה פריט באינדקס נתון בין כל הפריטים בטופס לאינדקס נתון אחר. הפונקציה מעלה חריגה של סקריפט אם האינדקס to חורג מהטווח.

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

פרמטרים

שםסוגתיאור
fromIntegerהאינדקס הנוכחי של הפריט מבין כל הפריטים בטופס.
toIntegerהאינדקס החדש של הפריט מבין כל הפריטים בטופס.

חזרה

Item — הפריט שהועבר.

מקפיצה את הודעות השגיאה (Throws)

Error – אם אחד מהאינדקסים חורג מהגבולות.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

moveItem(item, toIndex)

מעביר פריט נתון לאינדקס נתון מבין כל הפריטים בטופס. הפונקציה מעלה חריגה של סקריפטים אם האינדקס שצוין חורג מהגבולות.

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

פרמטרים

שםסוגתיאור
itemItemהפריט שרוצים להעביר.
toIndexIntegerהאינדקס החדש של הפריט מבין כל הפריטים בטופס.

חזרה

Item — הפריט שהועבר.

מקפיצה את הודעות השגיאה (Throws)

Error – אם האינדקס חורג מהגבולות.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

removeDestination()

ביטול הקישור של הטופס ליעד התשובות הנוכחי שלו. היעד הקודם שלא מקושר עדיין מכיל עותק של כל התגובות הקודמות. כל הטפסים, כולל אלה שלא הוגדר להם יעד באופן מפורש, שומרים עותק של התשובות במאגר התשובות של הטופס. אם לטופס אין כרגע יעד לתגובות, לשיטה הזו אין השפעה.

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

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

removeEditor(emailAddress)

מסיר את המשתמש שצוין מרשימת העורכים של Form. השיטה הזו לא חוסמת את הגישה של משתמשים ל-Form אם הם שייכים לקבוצת משתמשים שיש להם גישה כללית – לדוגמה, אם ה-Form משותף עם כל הדומיין של המשתמש, או אם ה-Form נמצא באחסון שיתופי שהמשתמש יכול לגשת אליו.

בקבצים ב-Drive, הפעולה הזו מסירה את המשתמש גם מרשימת הצופים והמשיבים.

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

פרמטרים

שםסוגתיאור
emailAddressStringכתובת האימייל של המשתמש שרוצים להסיר.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

removeEditor(user)

מסיר את המשתמש שצוין מרשימת העורכים של Form. השיטה הזו לא חוסמת את הגישה של משתמשים ל-Form אם הם שייכים לקבוצת משתמשים שיש להם גישה כללית – לדוגמה, אם ה-Form משותף עם כל הדומיין של המשתמש, או אם ה-Form נמצא באחסון שיתופי שהמשתמש יכול לגשת אליו.

בקבצים ב-Drive, הפעולה הזו מסירה את המשתמש גם מרשימת הצופים.

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

פרמטרים

שםסוגתיאור
userUserייצוג של המשתמש שרוצים להסיר.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

removePublishedReader(emailAddress)

מסירה את המשתמש שצוין מרשימת המשיבים של Form. השיטה הזו לא חוסמת את הגישה של משתמשים אל Form אם הם שייכים לסוג משתמשים שיש להם גישה כללית – לדוגמה, אם Form משותף עם הדומיין כולו של המשתמש, או אם Form נמצא באחסון שיתופי שהמשתמש יכול לגשת אליו.

בקבצים ב-Drive, הפעולה הזו מסירה את המשתמש גם מרשימת הצופים והעורכים.

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

פרמטרים

שםסוגתיאור
emailAddressStringכתובת האימייל של המשתמש שרוצים להסיר.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

removePublishedReader(user)

מסירה את המשתמש שצוין מרשימת המשיבים של Form. השיטה הזו לא חוסמת את הגישה של משתמשים אל Form אם הם שייכים לסוג משתמשים שיש להם גישה כללית – לדוגמה, אם Form משותף עם הדומיין כולו של המשתמש, או אם Form נמצא באחסון שיתופי שהמשתמש יכול לגשת אליו.

בקבצים ב-Drive, הפעולה הזו מסירה את המשתמש גם מרשימת הצופים והעורכים.

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

פרמטרים

שםסוגתיאור
userUserייצוג של המשתמש שרוצים להסיר.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setAcceptingResponses(enabled)

הגדרה של קבלת תשובות לטופס. ברירת המחדל לטפסים חדשים היא 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());

פרמטרים

שםסוגתיאור
enabledBooleantrue אם הטופס צריך לקבל תשובות; false אם הוא לא צריך לקבל תשובות.

חזרה

FormForm, לשרשור.

מקפיצה את הודעות השגיאה (Throws)

Error – אם האפשרות הזו מופעלת בטופס שהפרסום שלו בוטל.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setAllowResponseEdits(enabled)

הגדרה של הצגת קישור לעריכת תשובה בטופס אחרי שליחתה. ברירת המחדל לטפסים חדשים היא false.

ללא קשר להגדרה הזו, השיטה FormResponse.getEditResponseUrl() מאפשרת ליוצר סקריפט שיש לו הרשאת עריכה בטופס ליצור כתובת URL שאפשר להשתמש בה כדי לערוך תשובה.

// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// 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());

פרמטרים

שםסוגתיאור
enabledBooleantrue אם רוצים שהטופס יציג את הקישור 'עריכת התשובה שלך'. false אם לא רוצים.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setCollectEmail(collect)

הגדרה של איסוף כתובות האימייל של המשיבים בטופס. ברירת המחדל לטפסים חדשים היא 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);

פרמטרים

שםסוגתיאור
collectBooleantrue אם הטופס צריך לאסוף כתובות אימייל, false אם לא.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setConfirmationMessage(message)

הגדרת הודעת האישור של הטופס.

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

פרמטרים

שםסוגתיאור
messageStringהודעת האישור החדשה של הטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setCustomClosedFormMessage(message)

הגדרת ההודעה שתוצג אם הטופס לא מקבל תשובות. אם לא מגדירים הודעה, הטופס משתמש בהודעת ברירת מחדל.

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

פרמטרים

שםסוגתיאור
messageStringההודעה שתוצג אם אי אפשר לשלוח תשובות לטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setDescription(description)

הגדרת התיאור של הטופס.

פרמטרים

שםסוגתיאור
descriptionStringהתיאור החדש של הטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setDestination(type, id)

ההגדרה הזו קובעת את היעד שבו נשמרות התשובות לטופס. כל הטפסים, כולל אלה שלא הוגדר להם יעד באופן מפורש, שומרים עותק של התגובות במאגר התגובות של הטופס.

פרמטרים

שםסוגתיאור
typeDestinationTypeסוג היעד של התשובות לטופס.
idStringהמזהה של יעד התשובות של הטופס.

חזרה

FormForm, לשרשור.

מקפיצה את הודעות השגיאה (Throws)

Error — אם מזהה היעד שצוין לא תקין

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setIsQuiz(enabled)

הגדרה אם הטופס הוא בוחן. ברירת המחדל לטפסים חדשים היא false.

אפשר להשתמש בשאלות עם ציון רק בבחנים, ולכן אם מגדירים את האפשרות הזו לערך false, כל אפשרויות מתן הציונים יוסרו מכל השאלות.

הגדרות הבוחן זמינות רק בממשק המשתמש החדש של Forms. כשמגדירים טופס כבוחן, הטופס עובר לשימוש בממשק המשתמש החדש.

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

פרמטרים

שםסוגתיאור
enabledBooleantrue אם צריך להפעיל את תכונות הבוחן בטופס; false אם לא.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setLimitOneResponsePerUser(enabled)

הגדרה של האפשרות שכל משיב יוכל לשלוח רק תשובה אחת לטופס. ברירת המחדל לטפסים חדשים היא false. אם הערך מוגדר כ-true, הסקריפט לא יכול לשלוח תגובות לטופס בכלל.

פרמטרים

שםסוגתיאור
enabledBooleantrue אם הטופס צריך לאפשר רק תשובה אחת לכל משיב, false אם לא.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setProgressBar(enabled)

קובע אם בטופס יוצג סרגל התקדמות. ברירת המחדל לטפסים חדשים היא 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());

פרמטרים

שםסוגתיאור
enabledBooleantrue אם מוצג סרגל התקדמות בטופס, false אם לא מוצג סרגל התקדמות.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setPublished(enabled)

קובעת אם הטופס פורסם. ברירת המחדל לטפסים חדשים היא true.

התכונה הזו זמינה רק בטפסים שתומכים בפרסום. משתמשים בלחצן supportsAdvancedResponderPermissions() כדי לבדוק אם הטופס תומך בפרסום.

כדי שהמשיבים יוכלו לגשת לטופס, צריך לפרסם אותו. השיטה הזו מחליפה קריאות ל-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());

פרמטרים

שםסוגתיאור
enabledBooleantrue אם הטופס צריך להתפרסם, false אם לא.

חזרה

FormForm, לשרשור.

מקפיצה את הודעות השגיאה (Throws)

Error – אם מתקשרים לגבי טפסים שלא נתמכים.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setPublishingSummary(enabled)

קובעת אם בטופס יוצג קישור לצפייה בסיכום התשובות אחרי שהמשיב ישלח את הטופס. ברירת המחדל לטפסים חדשים היא false.

פרמטרים

שםסוגתיאור
enabledBooleantrue אם רוצים שהקישור 'צפייה בתשובות הקודמות' יוצג בטופס, false אם לא רוצים.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setShowLinkToRespondAgain(enabled)

ההגדרה הזו קובעת אם יוצג בטופס קישור לשליחת תגובה נוספת אחרי שהמשיב מסיים למלא את הטופס. ברירת המחדל לטפסים חדשים היא true.

פרמטרים

שםסוגתיאור
enabledBooleantrue אם בטופס צריך להופיע הקישור 'שליחת תשובה נוספת' false או לא.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setShuffleQuestions(shuffle)

הגדרה של סדר אקראי לשאלות בכל דף בטופס.

פרמטרים

שםסוגתיאור
shuffleBooleantrue אם הסדר של השאלות בכל דף בטופס צריך להיות אקראי, false אחרת.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

setTitle(title)

הגדרת הכותרת של הטופס.

פרמטרים

שםסוגתיאור
titleStringהכותרת החדשה של הטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

shortenFormUrl(url)

ממירה כתובת URL ארוכה של טופס לכתובת URL קצרה. מוחזרת חריגה אם כתובת ה-URL הארוכה לא שייכת ל-Google Forms.

פרמטרים

שםסוגתיאור
urlStringכתובת ה-URL לקיצור.

חזרה

String – כתובת URL בפורמט http://goo.gl/forms/1234.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

submitGrades(responses)

שליחת ציונים עבור תשובות ספציפיות בטופס.

אם הקוד כולל טריגר onFormSubmit, קריאה ל-submitGrades() מפעילה את התנאי onFormSubmit וגורמת ללולאה אינסופית. כדי למנוע את הלולאה האינסופית, מוסיפים קוד שבודק אם הציונים כבר קיימים לפני שמפעילים את submitGrades().

פרמטרים

שםסוגתיאור
responsesFormResponse[]מערך של כל התשובות בטופס.

חזרה

FormForm, לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

supportsAdvancedResponderPermissions()

קובעת אם הטופס תומך בפרסום. השיטה הזו משמשת כדי לקבוע אם השיטות setPublished(enabled) ו-isPublished() וההרשאות של המשיב זמינות.

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

חזרה

Booleantrue אם הטופס תומך בפרסום, false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:

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

שיטות שהוצאו משימוש