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新しい質問項目を列と行のグリッドとして追加します。これにより、 一連のチェックボックスから 1 行につき複数の選択肢を回答した回答者。
addCheckboxItem()CheckboxItem新しい質問項目を追加します。これにより、回答者は 1 つ以上のチェックボックスを 任意で「other」と表示されます。
addDateItem()DateItem回答者が日付を示す新しい質問項目を追加します。
addDateTimeItem()DateTimeItem新しい質問項目を追加し、回答者が日時を指定できるようにします。
addDurationItem()DurationItem新しい質問項目を追加し、回答者が時間の長さを指定できるようにします。
addEditor(emailAddress)Form指定されたユーザーを Form の編集者のリストに追加します。
addEditor(user)Form指定されたユーザーを Form の編集者のリストに追加します。
addEditors(emailAddresses)Form指定されたユーザー配列を Form の編集者のリストに追加します。
addGridItem()GridItem新しい質問項目を列と行のグリッドとして追加します。これにより、 一連のラジオボタンから 1 行に 1 つの選択肢を選択するという回答者の割合。
addImageItem()ImageItem画像を表示する新しいレイアウト アイテムを追加します。
addListItem()ListItem新しい質問項目を追加し、回答者がプルダウンから 1 つの選択肢を選択できるようにします 選択します。
addMultipleChoiceItem()MultipleChoiceItem新しい質問項目を追加し、回答者がラジオボタンのリストから 1 つの選択肢を選択できるようにします オプションの「その他」ボタンを表示されます。
addPageBreakItem()PageBreakItemページの先頭をマークする新しいレイアウト アイテムを追加します。
addParagraphTextItem()ParagraphTextItem回答者がテキスト ブロックを入力できる新しい質問項目を追加します。
addScaleItem()ScaleItem新しい質問項目を追加し、回答者が番号付き質問から 1 つの選択肢を選択できるようにします ラジオボタンです。
addSectionHeaderItem()SectionHeaderItemセクションの先頭を視覚的に表す新しいレイアウト アイテムを追加します。
addTextItem()TextItem新しい質問項目を追加し、回答者がテキストを 1 行入力できるようにします。
addTimeItem()TimeItem回答者が時間帯を示す新しい質問項目を追加します。
addVideoItem()VideoItem動画を表示する新しいレイアウト アイテムを追加します。
canEditResponse()Boolean送信後に回答を編集するためのリンクをフォームに表示するかどうかを決定します。
collectsEmail()Booleanフォームで回答者を収集するかどうかを決定します入力します。
createResponse()FormResponseフォームへの新しい回答を作成します。
deleteAllResponses()Form送信されたすべての回答をフォームのレスポンス ストアから削除します。
deleteItem(index)voidフォーム内のすべてのアイテムの中から、指定されたインデックスにあるアイテムを削除します。
deleteItem(item)void指定した項目を削除します。
deleteResponse(responseId)Formフォームのレスポンス ストアから 1 つのレスポンスを削除します。
getConfirmationMessage()Stringフォームの確認メッセージを取得します。
getCustomClosedFormMessage()Stringフォームが回答を受け付けていない場合、またはフォームが空の場合に表示されるカスタム メッセージを取得します。 カスタム メッセージが設定されていない場合は文字列。
getDescription()Stringフォームの説明を取得します。
getDestinationId()Stringフォームのレスポンス先の ID を取得します。
getDestinationType()DestinationTypeフォームのレスポンス先のタイプを取得します。
getEditUrl()Stringフォームの編集モードへのアクセスに使用できる URL を取得します。
getEditors()User[]この Form の編集者のリストを取得します。
getId()Stringフォームの ID を取得します。
getItemById(id)Item指定された ID のアイテムを取得します。
getItems()Item[]フォーム内のすべての項目の配列を取得します。
getItems(itemType)Item[]指定された型のすべてのアイテムの配列を取得します。
getPublishedUrl()Stringフォームへの回答に使用できる URL を取得します。
getResponse(responseId)FormResponseレスポンス ID に基づいて 1 つのフォーム レスポンスを取得します。
getResponses()FormResponse[]フォームのすべてのレスポンスの配列を取得します。
getResponses(timestamp)FormResponse[]指定された日時以降のすべてのフォームの回答の配列を取得します。
getShuffleQuestions()Booleanフォームの各ページにある質問の順序をランダム化するかどうかを決定します。
getSummaryUrl()Stringフォームの回答の概要の表示に使用できる URL を取得します。
getTitle()Stringフォームのタイトルを取得します。
hasLimitOneResponsePerUser()Booleanフォームで回答者 1 人につき回答を 1 つだけ許可するかどうかを指定します。
hasProgressBar()Booleanフォームに進行状況バーを表示するかどうかを決定します。
hasRespondAgainLink()Boolean回答者の後に別の回答を送信するためのリンクをフォームに表示するかどうかを指定します フォームに入力します。
isAcceptingResponses()Booleanフォームが現在回答を受け付けているかどうかを確認します。
isPublishingSummary()Boolean回答者の後に回答の概要を表示するリンクをフォームに表示するかどうかを指定します フォームに入力します。
isQuiz()Booleanフォームがクイズかどうかを決定します。
moveItem(from, to)Itemフォーム内のすべてのアイテムの中から、指定されたインデックスのアイテムを別の指定されたインデックスに移動します。
moveItem(item, toIndex)Itemフォームに含まれるすべてのアイテムの中から、指定されたアイテムを特定のインデックスに移動します。
removeDestination()Form現在の回答先からフォームのリンクを解除します。
removeEditor(emailAddress)FormForm の編集者のリストから指定したユーザーを削除します。
removeEditor(user)FormForm の編集者のリストから指定したユーザーを削除します。
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フォームで、回答者 1 人につき 1 件の回答のみを許可するかどうかを設定します。
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指定された FormResponses の成績を送信します。

詳細なドキュメント

addCheckboxGridItem()

新しい質問項目を列と行のグリッドとして追加します。これにより、 一連のチェックボックスから 1 行につき複数の選択肢を回答した回答者。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addCheckboxItem()

新しい質問項目を追加します。これにより、回答者は 1 つ以上のチェックボックスを 任意で「other」と表示されます。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addEditor(emailAddress)

指定されたユーザーを Form の編集者のリストに追加します。ユーザーがすでに 閲覧者のリストに含まれていた場合、このメソッドでは閲覧者のリストからユーザーを昇格できます。

パラメータ

名前説明
emailAddressString追加するユーザーのメールアドレス。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addEditor(user)

指定されたユーザーを Form の編集者のリストに追加します。ユーザーがすでに 閲覧者のリストに含まれていた場合、このメソッドでは閲覧者のリストからユーザーを昇格できます。

パラメータ

名前説明
userUser追加するユーザーの表現。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addEditors(emailAddresses)

指定されたユーザー配列を Form の編集者のリストに追加します。もし ユーザーがすでに閲覧者リストに含まれていた場合、この方法では閲覧者リストから昇格します。 できます。

パラメータ

名前説明
emailAddressesString[]追加するユーザーのメールアドレスの配列。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addGridItem()

新しい質問項目を列と行のグリッドとして追加します。これにより、 一連のラジオボタンから 1 行に 1 つの選択肢を選択するという回答者の割合。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addListItem()

新しい質問項目を追加し、回答者がプルダウンから 1 つの選択肢を選択できるようにします 選択します。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addMultipleChoiceItem()

新しい質問項目を追加し、回答者がラジオボタンのリストから 1 つの選択肢を選択できるようにします オプションの「その他」ボタンを表示されます。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addScaleItem()

新しい質問項目を追加し、回答者が番号付き質問から 1 つの選択肢を選択できるようにします ラジオボタンです。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

addTextItem()

新しい質問項目を追加し、回答者がテキストを 1 行入力できるようにします。

// 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 新しく作成されたアイテム。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 できません。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 に設定します。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

createResponse()

フォームへの新しい回答を作成します。質問項目に回答するには、ItemResponse を作成します その後、FormResponse.withItemResponse(response) を呼び出してこのフォームのレスポンスに添付します。作成されたレスポンスを保存するには、FormResponse.submit() を呼び出します。

戻る

FormResponse - 新しく作成されたフォームの回答。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

deleteAllResponses()

送信されたすべての回答をフォームのレスポンス ストアから削除します。このメソッドでは、 外部の回答先(スプレッドシートなど)に保存された回答のコピー。ただし、 フォームの概要ビューをクリアします。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - 指定されたインデックスにアイテムが存在しない場合

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - アイテムがフォームに存在しない場合

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

deleteResponse(responseId)

フォームのレスポンス ストアから 1 つのレスポンスを削除します。このメソッドでは、 外部の回答先(スプレッドシートなど)に保存されている回答のうち、 回答を確認できます。レスポンス ID は FormResponse.getId() で取得できます。

<ph type="x-smartling-placeholder">

パラメータ

名前説明
responseIdString削除するフォーム回答の ID。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - フォームの確認メッセージ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - フォームが回答を受け付けていない場合、またはフォームが空の場合に表示するカスタム メッセージ カスタム メッセージが設定されていない場合は文字列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - フォームの説明。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getDestinationId()

フォームのレスポンス先の ID を取得します。

// 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 - フォームの回答先の ID。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - フォームの回答先のタイプ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getEditors()

この Form の編集者のリストを取得します。

戻る

User[] - 編集権限を持つユーザーの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getId()

フォームの ID を取得します。

// 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 - フォームの ID。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getItemById(id)

指定された ID のアイテムを取得します。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商品アイテムの ID。

戻る

Item - 指定された ID を持つアイテム。アイテムがフォームに存在しない場合は null

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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[] - フォーム内のすべての項目の配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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[] - その型のすべての項目の配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getResponse(responseId)

レスポンス ID に基づいて 1 つのフォーム レスポンスを取得します。レスポンス ID は FormResponse.getId() から取得できます。

パラメータ

名前説明
responseIdStringフォームの回答の ID。

戻る

FormResponse - フォームの回答。

例外

Error - レスポンスが存在しない場合

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getResponses()

フォームのすべてのレスポンスの配列を取得します。

戻る

FormResponse[] - フォームのすべてのレスポンスの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getResponses(timestamp)

指定された日時以降のすべてのフォームの回答の配列を取得します。

パラメータ

名前説明
timestampDateフォームの回答を返す最も早い日時。

戻る

FormResponse[] - フォームの回答のリスト。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

getShuffleQuestions()

フォームの各ページにある質問の順序をランダム化するかどうかを決定します。

戻る

Boolean - フォームの各ページにある質問の順序がランダム化されている場合は true。 そうでない場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - フォームのタイトル。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

hasLimitOneResponsePerUser()

フォームで回答者 1 人につき回答を 1 つだけ許可するかどうかを指定します。値が true の場合、スクリプトはフォームの回答を送信できません。

戻る

Boolean - フォームで回答者 1 人につき回答が 1 回のみの場合は true、そうでない場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 に設定します。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 できません。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

戻る

Boolean - フォームが回答を受け付けている場合は true。そうでない場合は false に設定します。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 できません。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

戻る

Boolean - フォームが回答を受け付けている場合は true。そうでない場合は false に設定します。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - いずれかのインデックスが境界外の場合。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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 - インデックスが境界外の場合。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

removeEditor(emailAddress)

Form の編集者のリストから指定したユーザーを削除します。この方法では 次のクラスのユーザーに属している場合、Form へのアクセスをブロックします。 (たとえば、Form がユーザーの組織全体で共有されている場合、 Form が、ユーザーがアクセスできる共有ドライブ内にあるかどうかも確認できます。

ドライブのファイルの場合、閲覧者のリストからユーザーが削除されます。

パラメータ

名前説明
emailAddressString削除するユーザーのメールアドレス。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

removeEditor(user)

Form の編集者のリストから指定したユーザーを削除します。この方法では 次のクラスのユーザーに属している場合、Form へのアクセスをブロックします。 (たとえば、Form がユーザーの組織全体で共有されている場合、 Form が、ユーザーがアクセスできる共有ドライブ内にあるかどうかも確認できます。

ドライブのファイルの場合、閲覧者のリストからユーザーが削除されます。

パラメータ

名前説明
userUser削除するユーザーの表現。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

パラメータ

名前説明
enabledBooleanフォームが回答を受け入れる場合は true。すべきでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

パラメータ

名前説明
enabledBooleanフォームに「回答を編集」を表示する場合は trueリンクそうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

パラメータ

名前説明
collectBooleanフォームでメールアドレスを収集する場合は、true。次の場合は false できません。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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フォームの新しい確認メッセージ。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • 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フォームが回答を受け付けていない場合に表示するメッセージ。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setDescription(description)

フォームの説明を設定します。

パラメータ

名前説明
descriptionStringフォームの新しい説明。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setDestination(type, id)

フォームの回答の保存先を設定します。すべてのフォーム( 明示的に設定していない場合は、回答のコピーをフォームの レスポンス ストア

パラメータ

名前説明
typeDestinationTypeフォームのレスポンス先のタイプ。
idStringフォームの回答先の ID。

戻る

Form - この Form(チェーン用)。

例外

Error - 指定されたリンク先 ID が無効な場合

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setIsQuiz(enabled)

フォームがクイズかどうかを設定します。新規フォームのデフォルトは false です。

採点式の質問はクイズでのみ使用できるため、これを false に設定すると、 すべての質問から採点オプションが削除されます。

クイズの設定は、新しいフォーム UI でのみご利用いただけます。フォームをクイズにすると 詳しく見ていきましょう

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

パラメータ

名前説明
enabledBooleanフォームでクイズ機能を有効にする場合は true。次の場合は false できません。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setLimitOneResponsePerUser(enabled)

フォームで、回答者 1 人につき 1 件の回答のみを許可するかどうかを設定します。新規フォームのデフォルトは false。値が true に設定されている場合、スクリプトは次の場所でフォームの回答を送信できません。 できます。

パラメータ

名前説明
enabledBooleantrue: 回答者 1 人につき回答を 1 つだけ許可する場合に指定します。そうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

パラメータ

名前説明
enabledBooleanフォームに進行状況バーを表示する場合は true、そうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setPublishingSummary(enabled)

回答者の送信後に回答の概要を表示するリンクをフォームに表示するかどうかを設定します フォームに入力します。新規フォームのデフォルトは false です。

パラメータ

名前説明
enabledBooleanフォームに「以前の回答を表示」を表示する場合は trueリンクそうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

パラメータ

名前説明
requireLoginBooleanフォームでユーザーにログインを要求する場合は true。次の場合は false できません。

戻る

Form - 現在のフォーム(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setShowLinkToRespondAgain(enabled)

回答者の完了後に別の回答を送信するためのリンクをフォームに表示するかどうかを設定します フォームに入力します。新規フォームのデフォルトは true です。

パラメータ

名前説明
enabledBooleanフォームに「別の回答を送信」を表示する場合は trueリンクそうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setShuffleQuestions(shuffle)

フォームの各ページにある質問の順序をランダム化するかどうかを設定します。

パラメータ

名前説明
shuffleBooleanフォームの各ページにある質問の順序を次のとおりにする場合は、true ランダム化しそうでない場合は false

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

setTitle(title)

フォームのタイトルを設定します。

パラメータ

名前説明
titleStringフォームの新しいタイトル。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

shortenFormUrl(url)

フォームの長い URL を短縮 URL に変換します。長い URL が一致しない場合、例外をスローします。 Google フォームのものです。

パラメータ

名前説明
urlString短縮する URL。

戻る

String - http://goo.gl/forms/1234 形式の URL。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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

submitGrades(responses)

指定された FormResponses の成績を送信します。

コードに onFormSubmit トリガーが含まれていて、submitGrades() を呼び出す場合 onFormSubmit 条件をトリガーし、無限ループを発生させます。発生しないようにするため、 無限ループにするには、submitGrades() を呼び出す前に成績がすでに存在するかどうかを確認するコードを追加します。

パラメータ

名前説明
responsesFormResponse[]フォームのすべてのレスポンスの配列。

戻る

Form - この Form(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

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