全体的なプロパティと項目を含むフォーム。プロパティには、タイトル、設定、レスポンスの保存先が含まれます。項目にはチェックボックスやラジオボタンなどの質問項目があり、レイアウト項目は改ページなどを指します。フォームには 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());
Methods
メソッド | 戻り値の型 | 概要 |
---|---|---|
addCheckboxGridItem() | CheckboxGridItem | 列と行のグリッドとして表示される新しい質問アイテムを追加し、回答者が一連のチェックボックスから行ごとに複数の選択肢を選択できるようにします。 |
addCheckboxItem() | CheckboxItem | 回答者がチェックボックスを 1 つ以上選択できるようにする新しい質問項目と、オプションの「その他」項目を追加します。 |
addDateItem() | DateItem | 回答者が日付を確認できる新しい質問項目を追加します。 |
addDateTimeItem() | DateTimeItem | 回答者が日付と時刻を指定できる新しい質問項目を追加します。 |
addDurationItem() | DurationItem | 回答者が回答できる時間を示す新しい質問項目を追加します。 |
addEditor(emailAddress) | Form | 指定したユーザーを Form の編集者のリストに追加します。 |
addEditor(user) | Form | 指定したユーザーを Form の編集者のリストに追加します。 |
addEditors(emailAddresses) | Form | 指定したユーザー配列を Form の編集者のリストに追加します。 |
addGridItem() | GridItem | 列と行のグリッドとして表示される新しい質問項目が追加されます。これにより、回答者はラジオボタンのシーケンスから行ごとに 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 に基づいて単一のフォーム レスポンスを取得します。 |
getResponses() | FormResponse[] | フォームのレスポンスをすべて配列で取得します。 |
getResponses(timestamp) | FormResponse[] | 指定した日時以降のすべてのフォームの回答の配列を取得します。 |
getShuffleQuestions() | Boolean | フォームの各ページにおける質問の順序をランダム化するかどうかを決定します。 |
getSummaryUrl() | String | フォームの回答の概要の表示に使用できる URL を取得します。 |
getTitle() | String | フォームのタイトルを取得します。 |
hasLimitOneResponsePerUser() | Boolean | フォームで回答者ごとに 1 つの回答のみを許可するかどうかを指定します。 |
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 | フォームで回答者ごとに 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()
列と行のグリッドとして表示される新しい質問項目が追加されます。回答者は、一連のチェックボックスから行ごとに複数の選択肢を選択できます。
// 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 つ以上のチェックボックスを選択できる新しい質問項目と、オプションの「その他」フィールドを追加します。
// 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()
回答者が日付を確認できる新しい質問項目を追加します。
戻る
DateItem
- 新しく作成されたアイテム
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addDateTimeItem()
回答者が日付と時刻を指定できる新しい質問項目を追加します。
戻る
DateTimeItem
- 新しく作成されたアイテム
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addDurationItem()
回答者が回答できる時間を示す新しい質問項目を追加します。
戻る
DurationItem
- 新しく作成されたアイテム
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addEditor(emailAddress)
addEditor(user)
addEditors(emailAddresses)
指定したユーザー配列を Form
の編集者のリストに追加します。すでにいずれかのユーザーが閲覧者のリストに含まれていた場合、このメソッドはユーザーを閲覧者のリストから選択します。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
emailAddresses | String[] | 追加するユーザーのメールアドレスの配列。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addGridItem()
新しい質問項目が追加されます。これは、列と行のグリッドとして表示されるもので、回答者はラジオボタンのシーケンスから行ごとに 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()
画像を表示する新しいレイアウト アイテムを追加します。
戻る
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()
回答者が時刻を指定できる新しい質問項目を追加します。
戻る
TimeItem
- 新しく作成されたアイテム
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
addVideoItem()
動画を表示する新しいレイアウト アイテムを追加します。
戻る
VideoItem
- 新しく作成されたアイテム
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
canEditResponse()
フォームの送信後にフォームを編集するためのリンクを表示するかどうかを指定します。
この設定に関係なく、メソッド FormResponse.getEditResponseUrl()
を使用すると、フォームの編集権限を持つスクリプト作成者は、レスポンスの編集に使用できる URL を生成できます。
戻る
Boolean
- フォームに [回答の編集] リンクを表示する場合は true
、そうでない場合は false
に設定します。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
collectsEmail()
createResponse()
フォームに新しい回答を作成します。質問に回答するには、項目から ItemResponse
を作成し、FormResponse.withItemResponse(response)
を呼び出してこのフォーム応答に添付します。作成したレスポンスを保存するには、FormResponse.submit()
を呼び出します。
戻る
FormResponse
- 新しく作成されたフォーム レスポンス
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteAllResponses()
deleteItem(index)
フォーム内のすべてのアイテムのうち、特定のインデックスにあるアイテムを削除します。指定されたインデックスにアイテムが存在しない場合、スクリプト例外をスローします。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
index | Integer | フォーム内のすべてのアイテムのインデックスです。 |
例外
Error
- 指定されたインデックスにアイテムが存在しない場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
deleteItem(item)
deleteResponse(responseId)
フォームのレスポンス ストアから 1 つのレスポンスを削除します。この方法では、外部の回答先(スプレッドシートなど)に保存されている回答のコピーは削除されませんが、フォームのサマリービューから回答は削除されます。レスポンス ID は FormResponse.getId()
で取得できます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
responseId | String | 削除するフォーム レスポンスの ID |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getConfirmationMessage()
getCustomClosedFormMessage()
getDescription()
getDestinationId()
getDestinationType()
フォームの回答先の種類を取得します。
戻る
DestinationType
- フォームの回答先の種類
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getEditUrl()
getEditors()
getId()
getItemById(id)
指定した ID のアイテムを取得します。ID がフォームのアイテムに対応していない場合、null
を返します。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
id | Integer | アイテムの ID |
戻る
Item
- 指定された ID を持つアイテムか、アイテムがフォームに存在しない場合は null
。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getItems()
フォーム内のすべてのアイテムの配列を取得します。
戻る
Item[]
- フォーム内のすべての項目の配列。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getItems(itemType)
getPublishedUrl()
getResponse(responseId)
レスポンス ID に基づいて単一のフォーム レスポンスを取得します。レスポンス ID は FormResponse.getId()
から取得できます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
responseId | String | フォーム レスポンスの 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)
指定した日時以降のすべてのフォームの回答の配列を取得します。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
timestamp | Date | フォームの回答を最も早く返す日時 |
戻る
FormResponse[]
- フォームの回答のリスト
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getShuffleQuestions()
getSummaryUrl()
フォームの回答の概要の表示に使用できる URL を取得します。setPublishingSummary(enabled)
が true
に設定されている場合を除き、フォームの編集権限を持つユーザーのみが URL にアクセスできます。
戻る
String
- レスポンスの概要を表示する URL
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getTitle()
hasLimitOneResponsePerUser()
hasProgressBar()
hasRespondAgainLink()
isAcceptingResponses()
isPublishingSummary()
isQuiz()
moveItem(from, to)
フォーム内のすべてのアイテム間で特定のインデックスのアイテムを別のインデックスに移動します。to
インデックスが境界外の場合、スクリプト例外をスローします。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
from | Integer | フォーム内のすべての商品アイテムの現在のインデックス |
to | Integer | フォーム内のすべてのアイテムのうち、そのアイテムの新しいインデックス |
戻る
Item
- 移動されたアイテム
例外
Error
- いずれかのインデックスが範囲外の場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
moveItem(item, toIndex)
フォーム内のすべてのアイテム間で、特定のアイテムを特定のインデックスに移動します。指定されたインデックスが境界外の場合、スクリプト例外をスローします。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
item | Item | 移動するアイテム |
toIndex | Integer | フォーム内のすべてのアイテムのうち、そのアイテムの新しいインデックス |
戻る
Item
- 移動されたアイテム
例外
Error
- インデックスが範囲外の場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeDestination()
現在の回答先とフォームのリンクを解除します。リンクを解除しても、以前のデスティネーションには以前のすべてのレスポンスのコピーが保持されます。デスティネーションを明示的に設定していないフォームも含め、すべてのフォームでフォームの回答ストアに回答のコピーを保存します。フォームに応答先がない場合、このメソッドは無効になります。
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeEditor(emailAddress)
Form
の編集者のリストから指定されたユーザーを削除します。このメソッドは、ユーザーが一般的なアクセス権を持つクラスに属している場合(Form
がユーザーのドメイン全体と共有されている場合や、Form
がユーザーが所有する共有ドライブ内にある場合など)、Form
へのアクセスをブロックしません。
ドライブ ファイルの場合は、閲覧者のリストからもそのユーザーが削除されます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
emailAddress | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
removeEditor(user)
Form
の編集者のリストから指定されたユーザーを削除します。このメソッドは、ユーザーが一般的なアクセス権を持つクラスに属している場合(Form
がユーザーのドメイン全体と共有されている場合や、Form
がユーザーが所有する共有ドライブ内にある場合など)、Form
へのアクセスをブロックしません。
ドライブ ファイルの場合は、閲覧者のリストからもそのユーザーが削除されます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
requiresLogin()
フォームで返信前に同じドメインまたはサブドメインのアカウントにログインするかどうかをフォームで決定します。
戻る
Boolean
- フォームへのログインを求める場合は true
、そうでない場合は false
setAcceptingResponses(enabled)
setAllowResponseEdits(enabled)
フォームの送信後にフォームを編集するためのリンクを表示するかどうかを指定します。新しいフォームのデフォルトは false
です。
この設定に関係なく、メソッド FormResponse.getEditResponseUrl()
を使用すると、フォームの編集権限を持つスクリプト作成者は、レスポンスの編集に使用できる URL を生成できます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
enabled | Boolean | true フォームに「回答の編集」リンクを表示する必要がある場合。false |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setCollectEmail(collect)
setConfirmationMessage(message)
setCustomClosedFormMessage(message)
setDescription(description)
setDestination(type, id)
フォームの回答を保存する場所を設定します。デスティネーションを明示的に設定していないフォームも含めて、すべてのフォームでフォームの回答ストアに回答のコピーを保存できます。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
type | DestinationType | フォームの回答先の種類 |
id | String | フォームの回答先の ID。 |
戻る
例外
Error
- 指定されたデスティネーション ID が無効である場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setIsQuiz(enabled)
フォームをテストかどうかを設定します。新しいフォームのデフォルトは false
です。
採点式の質問はテストでのみ使用できるため、これを false に設定すると、すべての質問から採点オプションがすべて削除されます。
クイズの設定は新しいフォーム UI でのみ利用できます。フォームを作成すると、フォームは新しい UI を使用するようになります。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
enabled | Boolean | フォームでテスト機能を有効にするには true 、有効にする場合は false にします |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setLimitOneResponsePerUser(enabled)
フォームで回答者ごとに 1 つの回答のみを許可するかどうかを指定します。新しいフォームのデフォルトは false
です。値を true
に設定した場合、スクリプトはフォームのレスポンスをまったく送信できません。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
enabled | Boolean | true (フォームで回答を 1 回しか送信できない場合、false は許可されない) |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setProgressBar(enabled)
setPublishingSummary(enabled)
setRequireLogin(requireLogin)
回答者が返信する前に同じドメインまたはサブドメインのアカウントにログインするかどうかをフォームで設定します。ドメイン管理者がデフォルトを変更しない限り、新しいフォームのデフォルトは false
になります。
この機能は、Google Workspace ユーザーが作成したフォームでのみご利用いただけます。他の種類の Google アカウントのユーザーはログインする必要がありません。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
requireLogin | Boolean | ユーザーにログインを求める場合は true 、そうでない場合は false |
戻る
Form
- 現在のフォーム(チェーンの場合)。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setShowLinkToRespondAgain(enabled)
setShuffleQuestions(shuffle)
setTitle(title)
shortenFormUrl(url)
submitGrades(responses)
指定された FormResponses の成績を送信します。
コードに onFormSubmit
トリガーが含まれている場合、submitGrades()
を呼び出すと onFormSubmit
条件がトリガーされ、無限ループが発生します。無限ループを防ぐには、submitGrades()
を呼び出す前に成績がすでに存在するかどうかを確認するコードを追加します。
パラメータ
氏名 | 型 | 説明 |
---|---|---|
responses | FormResponse[] |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms