全体的なプロパティと項目を含むフォーム。プロパティには、タイトル、設定、回答の保存場所が含まれます。アイテムには、チェックボックスやラジオボタンなどの質問アイテムが含まれます。レイアウト アイテムは、改ページなどを指します。フォームには Form からアクセスしたり、作成したりできます。
// Open a form by ID and create a new spreadsheet. const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); const ss = SpreadsheetApp.create('Spreadsheet Name'); // Update form properties via chaining. form.setTitle('Form Name') .setDescription('Description of form') .setConfirmationMessage('Thanks for responding!') .setAllowResponseEdits(true) .setAcceptingResponses(false); // Update the form's response destination. form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
add | Checkbox | 新しい質問項目を追加します。この項目は列と行のグリッドとして表示され、回答者はチェックボックスのシーケンスから行ごとに複数の選択肢を選択できます。 |
add | Checkbox | 回答者が 1 つ以上のチェックボックスと、必要に応じて「その他」フィールドを選択できる新しい質問項目を追加します。 |
add | Date | 回答者が日付を指定できる新しい質問項目を追加します。 |
add | Date | 回答者が日時を指定できる新しい質問項目を追加します。 |
add | Duration | 回答者が期間を指定できる新しい質問項目を追加します。 |
add | Form | 指定されたユーザーを Form の編集者のリストに追加します。 |
add | Form | 指定されたユーザーを Form の編集者のリストに追加します。 |
add | Form | 指定されたユーザーの配列を Form の編集者のリストに追加します。 |
add | Grid | 列と行のグリッドとして表示される新しい質問項目を追加します。回答者は、一連のラジオボタンから行ごとに 1 つの選択肢を選択できます。 |
add | Image | 画像を表示する新しいレイアウト アイテムを追加します。 |
add | List | 回答者がプルダウン リストから 1 つの選択肢を選択できる新しい質問項目を追加します。 |
add | Multiple | 回答者がラジオボタンのリストから 1 つの選択肢を選択できる新しい質問項目、またはオプションの「その他」フィールドを追加します。 |
add | Page | ページの開始を示す新しいレイアウト アイテムを追加します。 |
add | Paragraph | 回答者がテキスト ブロックを入力できる新しい質問項目を追加します。 |
add | Form | 指定されたユーザーを Form の回答者リストに追加します。 |
add | Form | 指定されたユーザーを Form の回答者リストに追加します。 |
add | Form | 指定されたユーザーの配列を Form の回答者のリストに追加します。 |
add | Rating | 回答者が評価を入力できる新しい質問項目を追加します。 |
add | Scale | 回答者が番号付きのラジオボタンのシーケンスから 1 つのオプションを選択できる新しい質問項目を追加します。 |
add | Section | セクションの開始を視覚的に示す新しいレイアウト アイテムを追加します。 |
add | Text | 回答者が 1 行のテキストを入力できる新しい質問項目を追加します。 |
add | Time | 回答者が時刻を指定できる新しい質問項目を追加します。 |
add | Video | 動画を表示する新しいレイアウト アイテムを追加します。 |
can | Boolean | フォームの送信後に回答を編集するためのリンクを表示するかどうかを指定します。 |
collects | Boolean | フォームで回答者のメールアドレスを収集するかどうかを指定します。 |
create | Form | フォームへの新しい回答を作成します。 |
delete | Form | フォームの回答ストアから送信されたすべての回答を削除します。 |
delete | void | フォーム内のすべてのアイテムのうち、指定されたインデックスにあるアイテムを削除します。 |
delete | void | 指定されたアイテムを削除します。 |
delete | Form | フォームの回答ストアから単一の回答を削除します。 |
get | String | フォームの確認メッセージを取得します。 |
get | String | フォームで回答を受け付けていない場合に表示されるカスタム メッセージを取得します。カスタム メッセージが設定されていない場合は、空の文字列を返します。 |
get | String | フォームの説明を取得します。 |
get | String | フォームの回答の保存先の ID を取得します。 |
get | Destination | フォームの回答先のタイプを取得します。 |
get | String | フォームの編集モードにアクセスするために使用できる URL を取得します。 |
get | User[] | この Form の編集者のリストを取得します。 |
get | String | フォームの ID を取得します。 |
get | Item|null | 指定された ID のアイテムを取得します。 |
get | Item[] | フォーム内のすべてのアイテムの配列を取得します。 |
get | Item[] | 指定された型のすべてのアイテムの配列を取得します。 |
get | User[] | この Form のレスポンダのリストを取得します。 |
get | String | フォームへの回答に使用できる URL を取得します。 |
get | Form | 回答 ID に基づいて、単一のフォームの回答を取得します。 |
get | Form | フォームのすべての回答の配列を取得します。 |
get | Form | 指定された日時以降のフォームのすべての回答の配列を取得します。 |
get | Boolean | フォームの各ページの質問の順序をランダムにするかどうかを指定します。 |
get | String | フォームの回答の概要を表示するために使用できる URL を取得します。 |
get | String | フォームのタイトルを取得します。 |
has | Boolean | フォームで回答者が 1 回だけ回答できるかどうかを指定します。 |
has | Boolean | フォームに進行状況バーを表示するかどうかを指定します。 |
has | Boolean | 回答者がフォームへの入力を完了した後に、別の回答を送信するためのリンクをフォームに表示するかどうかを指定します。 |
is | Boolean | フォームで現在回答を受け付けているかどうかを判断します。 |
is | Boolean | フォームが公開されているかどうかを判断します。 |
is | Boolean | 回答者がフォームを完了した後に、回答の概要を表示するリンクをフォームに表示するかどうかを指定します。 |
is | Boolean | フォームがテストかどうかを判断します。 |
move | Item | フォーム内のすべてのアイテムの中で、指定されたインデックスにあるアイテムを別の指定されたインデックスに移動します。 |
move | Item | フォーム内のすべてのアイテムの中で、指定されたアイテムを指定されたインデックスに移動します。 |
remove | Form | フォームと現在の回答先のリンクを解除します。 |
remove | Form | 指定されたユーザーを Form の編集者リストから削除します。 |
remove | Form | 指定されたユーザーを Form の編集者リストから削除します。 |
remove | Form | 指定されたユーザーを Form の回答者リストから削除します。 |
remove | Form | 指定されたユーザーを Form の回答者リストから削除します。 |
set | Form | フォームで現在回答を受け付けているかどうかを設定します。 |
set | Form | フォームの送信後に回答を編集するためのリンクを表示するかどうかを設定します。 |
set | Form | フォームで回答者のメールアドレスを収集するかどうかを設定します。 |
set | Form | フォームの確認メッセージを設定します。 |
set | Form | フォームで回答を受け付けていない場合に表示するメッセージを設定します。 |
set | Form | フォームの説明を設定します。 |
set | Form | フォームの回答の保存先を設定します。 |
set | Form | フォームがテストかどうかを設定します。 |
set | Form | フォームで回答者 1 人につき 1 回のみ回答を許可するかどうかを設定します。 |
set | Form | フォームに進行状況バーを表示するかどうかを設定します。 |
set | Form | フォームが公開されているかどうかを設定します。 |
set | Form | 回答者がフォームを送信した後に、回答の概要を表示するリンクをフォームに表示するかどうかを設定します。 |
set | Form | 回答者がフォームを完了した後に、別の回答を送信するためのリンクをフォームに表示するかどうかを設定します。 |
set | Form | フォームの各ページの問題の順序をランダム化するかどうかを設定します。 |
set | Form | フォームのタイトルを設定します。 |
shorten | String | フォームの長い URL を短い URL に変換します。 |
submit | Form | 指定された FormResponse の成績を送信します。 |
supports | Boolean | フォームが公開をサポートするかどうかを判断します。 |
詳細なドキュメント
add Checkbox Grid 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', ); // Adds a checkbox grid item. const item = form.addCheckboxGridItem(); item.setTitle('Where did you celebrate New Year\'s?'); // Sets the grid's rows and columns. item.setRows(['New York', 'San Francisco', 'London']).setColumns([ '2014', '2015', '2016', '2017' ]);
戻る
Checkbox - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Checkbox Item()
回答者が 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']);
戻る
Checkbox - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Date 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', ); // 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.');
戻る
Date - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Date Time 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', ); // 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);
戻る
Date - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Duration 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', ); // 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);
戻る
Duration - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Editor(emailAddress)
指定されたユーザーを Form の編集者のリストに追加します。ユーザーがすでに閲覧者または回答者のリストに登録されている場合、このメソッドはユーザーをリストから除外します。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds editor to the form. // TODO(developer): replace the emailAddress. form.addEditor('editor@uni.edu');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 追加するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Editor(user)
指定されたユーザーを Form の編集者のリストに追加します。ユーザーがすでに閲覧者または回答者のリストに登録されている場合、このメソッドはユーザーをリストから除外します。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the editors from the old form. const users = oldForm.getEditors(); // Creates a new form. const newForm = FormApp.create('New form'); // Adds the editors to a new form. users.forEach(user => newForm.addEditor(user));
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 追加するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Editors(emailAddresses)
指定されたユーザーの配列を Form の編集者のリストに追加します。ユーザーが視聴者リストにすでに含まれている場合、このメソッドは視聴者リストからユーザーを削除します。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds editors to the form. // TODO(developer): replace the emailAddress. form.addPublishedReaders(['editor1@uni.edu', 'editor2@uni.edu']);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String[] | 追加するユーザーのメールアドレスの配列。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Grid Item()
列と行のグリッドとして表示される新しい質問項目を追加します。回答者は、一連のラジオボタンから行ごとに 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' ]);
戻る
Grid - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Image 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', ); // 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);
戻る
Image - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add List Item()
回答者がプルダウン リストから 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')]);
戻る
List - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Multiple Choice Item()
回答者がラジオボタンのリストまたはオプションの「その他」フィールドから 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]);
戻る
Multiple - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Page Break 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', ); // 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);
戻る
Page - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Paragraph Text Item()
回答者がテキスト ブロックを入力できる新しい質問項目を追加します。
// 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?');
戻る
Paragraph - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Published Reader(emailAddress)
指定されたユーザーを Form の回答者のリストに追加します。ユーザーがすでに編集者または閲覧者のリストに登録されている場合、このメソッドは効果がありません。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds responder to the form. // TODO(developer): replace the emailAddress. form.addPublishedReader('responder@uni.edu');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 追加するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Published Reader(user)
指定されたユーザーを Form の回答者のリストに追加します。ユーザーがすでに編集者または閲覧者のリストに登録されている場合、このメソッドは効果がありません。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const oldForm = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders from the old form. const users = oldForm.getPublishedReaders(); // Creates a new form. const newForm = FormApp.create('New form'); // Adds the responders to a new form. users.forEach(user => newForm.addPublishedReader(user));
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 追加するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Published Readers(emailAddresses)
指定されたユーザーの配列を Form の回答者のリストに追加します。ユーザーがすでに編集者または閲覧者のリストに登録されている場合、このメソッドは効果がありません。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Adds responders to the form. // TODO(developer): replace the emailAddress. form.addPublishedReaders(['responder1@uni.edu', 'responder2@uni.edu']);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String[] | 追加するユーザーのメールアドレスの配列。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Rating 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', ); // Adds the rating item. const item = form.addRatingItem();
戻る
Rating - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Scale Item()
回答者が番号付きのラジオボタンのシーケンスから 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');
戻る
Scale - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Section Header 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', ); // 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');
戻る
Section - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Text Item()
回答者が 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?');
戻る
Text - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Time Item()
回答者が 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 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?');
戻る
Time - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
add Video 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', ); // 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);
戻る
Video - 新しく作成されたアイテム。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
can Edit Response()
フォームの送信後に回答を編集するためのリンクを表示するかどうかを指定します。
この設定に関係なく、Form メソッドを使用すると、フォームの編集権限を持つスクリプト作成者は、回答の編集に使用できる 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
collects Email()
フォームで回答者のメールアドレスを収集するかどうかを指定します。
// 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
create Response()
フォームへの新しい回答を作成します。質問項目に回答するには、項目から Item を作成し、Form を呼び出してこのフォームの回答に添付します。組み立てられたレスポンスを保存するには、Form を呼び出します。
戻る
Form - 新しく作成されたフォームの回答。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
delete All Responses()
delete Item(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); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
index | Integer | フォーム内のすべてのアイテムにおけるアイテムのインデックス。 |
例外
Error - 指定されたインデックスにアイテムが存在しない場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
delete Item(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); }
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
item | Item | 削除するアイテム。 |
例外
Error - フォームに項目が存在しない場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
delete Response(responseId)
フォームの回答ストアから単一の回答を削除します。この方法では、外部の回答先(スプレッドシートなど)に保存されている回答のコピーは削除されませんが、フォームの概要ビューから回答が削除されます。レスポンス ID は Form で取得できます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
response | String | 削除するフォームの回答の ID。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Confirmation 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 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
get Custom Closed Form 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 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
get Description()
フォームの説明を取得します。
// 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
get Destination Id()
フォームの回答の保存先の 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
get Destination Type()
フォームの回答先のタイプを取得します。
// 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);
戻る
Destination - フォームの回答先のタイプ。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Edit Url()
フォームの編集モードにアクセスするために使用できる 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
get Editors()
get Id()
フォームの 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
get Item By Id(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
id | Integer | アイテムの ID。 |
戻る
Item|null - 指定された ID を持つ項目。フォームに項目が存在しない場合は null。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Items()
フォーム内のすべてのアイテムの配列を取得します。
// 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
get Items(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
item | Item | 取得するアイテムのタイプ。 |
戻る
Item[] - そのタイプのすべてのアイテムの配列。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Published Readers()
この Form のレスポンダーのリストを取得します。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders for the form. const users = form.getPublishedReaders(); users.forEach(user => console.log(user.getEmail()));
戻る
User[] - 回答者の権限を持つユーザーの配列。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Published Url()
フォームへの回答に使用できる 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
get Response(responseId)
回答 ID に基づいて、単一のフォームの回答を取得します。レスポンス ID は Form から取得できます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
response | String | フォームの回答の ID。 |
戻る
Form - フォームの回答。
例外
Error - レスポンスが存在しない場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Responses()
フォームのすべての回答の配列を取得します。
戻る
Form - フォームのすべての回答の配列。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Responses(timestamp)
指定された日時以降のフォームのすべての回答の配列を取得します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
timestamp | Date | フォームの回答を返す最も早い日時。 |
戻る
Form - フォームの回答のリスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Shuffle Questions()
フォームの各ページの質問の順序をランダムにするかどうかを指定します。
戻る
Boolean - フォームの各ページの質問の順序がランダム化されている場合は true、そうでない場合は false。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Summary Url()
フォームの回答の概要を表示するために使用できる URL を取得します。set が 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
get Title()
フォームのタイトルを取得します。
// 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
has Limit One Response Per User()
フォームで回答者 1 人につき 1 回しか回答できないようにするかどうかを指定します。値が true の場合、スクリプトはフォームの回答を送信できません。
戻る
Boolean - 回答者 1 人につき 1 回の回答のみが許可されている場合は true、そうでない場合は false。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
has Progress Bar()
フォームに進行状況バーを表示するかどうかを指定します。
// 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
has Respond Again Link()
回答者がフォームへの入力を完了した後に、別の回答を送信するためのリンクをフォームに表示するかどうかを指定します。
// 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
is Accepting Responses()
フォームで現在回答を受け付けているかどうかを判断します。フォームの公開状態が変更されると、この値は上書きされます。
// 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
is Published()
フォームが公開されているかどうかを判断します。
この機能は、公開をサポートしているフォームでのみご利用いただけます。supports を使用して、フォームが公開をサポートしているかどうかを確認します。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Checks whether the form is published or not and logs it to the console. console.log(form.isPublished());
戻る
Boolean - フォームが公開されている場合は true、公開されていない場合は false。
例外
Error - サポートされていないフォームで呼び出された場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
is Publishing Summary()
回答者がフォームを完了した後に、回答の概要を表示するリンクをフォームに表示するかどうかを指定します。
// 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
is Quiz()
フォームがテストかどうかを判断します。
// 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
move Item(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
from | Integer | フォーム内のすべてのアイテムにおけるアイテムの現在のインデックス。 |
to | Integer | フォーム内のすべてのアイテムにおけるアイテムの新しいインデックス。 |
戻る
Item - 移動されたアイテム。
例外
Error - いずれかのインデックスが範囲外の場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
move Item(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
item | Item | 移動するアイテム。 |
to | Integer | フォーム内のすべてのアイテムにおけるアイテムの新しいインデックス。 |
戻る
Item - 移動されたアイテム。
例外
Error - インデックスが範囲外の場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
remove Destination()
フォームと現在の回答先のリンクを解除します。リンクが解除された以前の宛先には、以前のすべてのレスポンスのコピーが残っています。送信先が明示的に設定されていないフォームを含め、すべてのフォームで回答のコピーがフォームの回答ストアに保存されます。フォームに現在回答先がない場合、このメソッドは効力がありません。
// 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();
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
remove Editor(emailAddress)
指定されたユーザーを Form の編集者リストから削除します。このメソッドは、ユーザーが一般アクセス権を持つユーザーのクラスに属している場合(たとえば、Form がユーザーのドメイン全体と共有されている場合や、Form がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが Form にアクセスすることをブロックしません。
ドライブ ファイルの場合、閲覧者と回答者のリストからもユーザーが削除されます。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Removes the editor from the form. // TODO(developer): replace the emailAddress. form.removeEditor('editor@uni.edu');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
remove Editor(user)
指定されたユーザーを Form の編集者リストから削除します。このメソッドは、ユーザーが一般アクセス権を持つユーザーのクラスに属している場合(たとえば、Form がユーザーのドメイン全体と共有されている場合や、Form がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが Form にアクセスすることをブロックしません。
ドライブ ファイルの場合、この操作を行うと、閲覧者リストからもユーザーが削除されます。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the editors from the form. const users = form1.getEditors(); // Opens another form. // TODO(developer): Replace the URL with your own. const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit'); // Removes editors from the form. users.forEach(user => form2.removeEditor(user));
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
remove Published Reader(emailAddress)
指定されたユーザーを Form の回答者リストから削除します。この方法では、ユーザーが一般的なアクセス権を持つユーザーのクラスに属している場合(たとえば、Form がユーザーのドメイン全体と共有されている場合や、Form がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが Form にアクセスすることをブロックできません。
ドライブ ファイルの場合、閲覧者と編集者のリストからもユーザーが削除されます。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Removes the responders from the form. // TODO(developer): replace the emailAddress. form.removePublishedReader('responder1@uni.edu');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
email | String | 削除するユーザーのメールアドレス。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
remove Published Reader(user)
指定されたユーザーを Form の回答者リストから削除します。この方法では、ユーザーが一般的なアクセス権を持つユーザーのクラスに属している場合(たとえば、Form がユーザーのドメイン全体と共有されている場合や、Form がユーザーがアクセスできる共有ドライブにある場合など)、ユーザーが Form にアクセスすることをブロックできません。
ドライブ ファイルの場合、閲覧者と編集者のリストからもユーザーが削除されます。
// Opens the Forms file by its URL. // TODO(developer): Replace the URL with your own. const form1 = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit'); // Gets the responders from the form. const users = form1.getPublishedReaders(); // Opens another form. // TODO(developer): Replace the URL with your own. const form2 = FormApp.openByUrl('https://docs.google.com/forms/d/efg123456/edit'); // Removes responders from the form. users.forEach(user => form2.removePublishedReader(user));
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
user | User | 削除するユーザーの表現。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Accepting Responses(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());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームで回答を受け付ける場合は true、受け付けない場合は false。 |
戻る
例外
Error - 非公開のフォームで有効になっている場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Allow Response Edits(enabled)
フォームの送信後に回答を編集するためのリンクを表示するかどうかを設定します。新しいフォームのデフォルトは false です。
この設定に関係なく、フォームの編集権限を持つスクリプト作成者は、Form メソッドを使用して、回答の編集に使用できる 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());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームに [回答を編集] リンクを表示する場合は true、表示しない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Collect Email(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
collect | Boolean | フォームでメールアドレスを収集する場合は true、収集しない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Confirmation Message(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
message | String | フォームの新しい確認メッセージ。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Custom Closed Form Message(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);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
message | String | フォームで回答を受け付けていない場合に表示するメッセージ。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Description(description)
set Destination(type, id)
フォームの回答の保存先を設定します。送信先が明示的に設定されていないフォームを含め、すべてのフォームで、回答のコピーがフォームの回答ストアに保存されます。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
type | Destination | フォームの回答先のタイプ。 |
id | String | フォームの回答先の ID。 |
戻る
例外
Error - 指定された宛先 ID が無効な場合
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Is Quiz(enabled)
フォームがテストかどうかを設定します。新しいフォームのデフォルトは false です。
採点対象の質問は理解度チェックでのみ許可されるため、これを false に設定すると、すべての質問からすべての採点オプションが削除されます。
テストの設定は新しいフォームの UI でのみ利用できます。フォームをテストにすると、新しい 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());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームでテスト機能を有効にする場合は true、有効にしない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Limit One Response Per User(enabled)
フォームで回答者 1 人につき 1 回のみ回答を許可するかどうかを設定します。新しいフォームのデフォルトは false です。値が true に設定されている場合、スクリプトはフォームの回答を送信できません。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | 回答者ごとに 1 回の回答のみを許可する場合は true、それ以外の場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Progress Bar(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());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームに進行状況バーが表示される場合は true、表示されない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Published(enabled)
フォームが公開されているかどうかを設定します。新しいフォームのデフォルトは true です。
この機能は、公開をサポートしているフォームでのみご利用いただけます。supports を使用して、フォームが公開をサポートしているかどうかを確認します。
回答者がフォームにアクセスできるようにするには、フォームを公開する必要があります。このメソッドは、set の呼び出しに優先します。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Publishes the form before sharing it. form.setPublished(true); // Checks whether the form is published or not and logs it to the console. console.log(form.isPublished());
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームを公開する場合は true、公開しない場合は false。 |
戻る
例外
Error - サポートされていないフォームで呼び出された場合。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Publishing Summary(enabled)
回答者がフォームを送信した後に、回答の概要を表示するリンクをフォームに表示するかどうかを設定します。新しいフォームのデフォルトは false です。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームに [以前の回答を表示] リンクを表示する場合は true、表示しない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Show Link To Respond Again(enabled)
回答者がフォームを完了した後に、別の回答を送信するためのリンクをフォームに表示するかどうかを設定します。新しいフォームのデフォルトは true です。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
enabled | Boolean | フォームに [別の回答を送信] リンクを表示する場合は true、表示しない場合は false。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
set Shuffle Questions(shuffle)
set Title(title)
shorten Form Url(url)
フォームの長い URL を短い URL に変換します。長い URL が Google フォームに属していない場合は、例外をスローします。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
url | String | 短縮する URL。 |
戻る
String - http://goo.gl/forms/1234 形式の URL。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
submit Grades(responses)
指定された FormResponse の成績を送信します。
コードに on トリガーが含まれている場合、submit を呼び出すと on 条件がトリガーされ、無限ループが発生します。無限ループを防ぐため、submit を呼び出す前に成績がすでに存在するかどうかを確認するコードを追加します。
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
responses | Form | フォームのすべての回答の配列。 |
戻る
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
supports Advanced Responder Permissions()
フォームが公開をサポートするかどうかを判断します。このメソッドは、set メソッドと is メソッド、およびレスポンダ権限が利用可能かどうかを判断するために使用されます。
// Opens the Forms file by its URL. If you created your script from within a // Google Forms file, you can use FormApp.getActiveForm() instead. // TODO(developer): Replace the URL with your own. const form = FormApp.openByUrl( 'https://docs.google.com/forms/d/abc123456/edit', ); // Checks whether the form supports publishing or not and logs it to the // console. console.log(form.supportsAdvancedResponderPermissions());
戻る
Boolean - フォームが公開をサポートしている場合は true、サポートしていない場合は false。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms