Class Form

טופס

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

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

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

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

שיטות

שיטהסוג הערך שמוחזרתיאור קצר
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הוספת שאלה חדשה שמאפשרת למשיב להזין קטע טקסט.
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הפונקציה מקבלת את הפריט עם מזהה נתון.
getItems()Item[]הפונקציה מקבלת מערך של כל הפריטים בטופס.
getItems(itemType)Item[]הפונקציה מקבלת מערך של כל הפריטים מסוג נתון.
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ההגדרה קובעת אם הטופס מקבל כרגע תשובות.
isPublishingSummary()Booleanההגדרה הזו קובעת אם הטופס יציג קישור להצגת סיכום של התשובות אחרי שהמשיבים ממלאים את הטופס.
isQuiz()Booleanהגדרה זו קובעת אם הטופס הוא בוחן.
moveItem(from, to)Itemמעביר פריט באינדקס נתון בין כל הפריטים בטופס לאינדקס נתון אחר.
moveItem(item, toIndex)Itemמעביר פריט נתון לאינדקס נתון בין כל הפריטים בטופס.
removeDestination()Formביטול הקישור של הטופס ליעד התגובה הנוכחי שלו.
removeEditor(emailAddress)Formמסיר את המשתמש הנתון מרשימת העורכים של Form.
removeEditor(user)Formמסיר את המשתמש הנתון מרשימת העורכים של Form.
requiresLogin()Booleanהגדרה זו קובעת אם הטופס מחייב את המשיבים להתחבר לחשבון באותו דומיין או בתת-דומיין לפני שיוכלו להגיב.
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המדיניות הזו קובעת אם הטופס יכלול סרגל התקדמות.
setPublishingSummary(enabled)Formההגדרה קובעת אם הטופס יציג קישור להצגת סיכום של התגובות אחרי שהמשיב שולח את הטופס.
setRequireLogin(requireLogin)Formקובעת אם הטופס מחייב את המשיבים להתחבר לחשבון באותו דומיין או בתת-דומיין לפני שיוכלו להגיב.
setShowLinkToRespondAgain(enabled)Formההגדרה הזו קובעת אם הטופס יציג קישור לשליחת תשובה נוספת אחרי שהמשיב ממלא את הטופס.
setShuffleQuestions(shuffle)Formמגדירה אם סדר השאלות בכל דף בטופס יהיה אקראי.
setTitle(title)Formמגדיר את כותרת הטופס.
shortenFormUrl(url)Stringממירה כתובת URL ארוכה של טופס לכתובת URL קצרה.
submitGrades(responses)Formשליחת ציונים לתשובות שניתנו ב-Forms.

תיעוד מפורט

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

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

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

החזרות

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

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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

addEditor(user)

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

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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

addEditors(emailAddresses)

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

פרמטרים

שםתיאורהתיאור
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

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

החזרות

Boolean - true אם הטופס מציג קישור 'עריכת התשובה שלך'. אם לא, 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);

החזרות

Boolean - true אם מתבצע איסוף של כתובות אימייל בטופס, 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האינדקס של הפריט מבין כל הפריטים בטופס.

קליעות

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הפריט למחיקה.

קליעות

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 - כתובת האתר לעריכת הטופס.

הרשאות

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

  • 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 אם הפריט לא קיים בטופס.

הרשאות

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

  • 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

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 - התגובה לטופס.

קליעות

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

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

החזרות

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

החזרות

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

החזרות

Boolean - true אם בטופס מוצג סרגל התקדמות; 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());

החזרות

Boolean - true אם הטופס מציג קישור מסוג 'שליחת תגובה נוספת'; 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

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

החזרות

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

קליעות

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 - הפריט שהועבר.

קליעות

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, המשתמש יוסר גם מרשימת הצופים.

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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

removeEditor(user)

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

בקובצי Drive, המשתמש יוסר גם מרשימת הצופים.

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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

requiresLogin()

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

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

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

החזרות

Boolean - true אם הטופס מחייב את המשתמשים להיכנס לחשבון; false אם אין צורך בהתחברות.


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, לשרשור.

הרשאות

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

  • 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, לשרשור.

קליעות

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

setPublishingSummary(enabled)

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

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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

setRequireLogin(requireLogin)

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

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

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

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

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

פרמטרים

שםתיאורהתיאור
requireLoginBooleantrue אם המשתמשים נדרשים להתחבר בטופס; false אם לא.

החזרות

Form - הצורה הנוכחית (לשרשור).

הרשאות

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

  • 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)

שליחת ציונים לתשובות שניתנו ב-Forms.

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

פרמטרים

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

החזרות

FormForm, לשרשור.

הרשאות

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

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