LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

2017年11月12日日曜日

Google Formにスクリプトからsubmitする

Google Formを新規作成して
質問1に記述式テキストを配置した
こんなフォームを用意して


スクリプトから直接回答をsubmitしてシートに記録する

ということをやってみた時のコードです


このリンクから新規Google Formを作成できます
https://docs.google.com/forms/create


スクリプトエディタを開く方法は
こちら


コード.gsのmyFunction()を実行すると
回答シートの質問1にhelloが記録されます


コード.gs
function myFunction() {
  var form = FormApp.getActiveForm();
  var item = form.getItems()[0].asTextItem();
  var item_response = item_as.createResponse("hello");
  var create_response = form.createResponse();
  create_response.withItemResponse(item_response).submit();
}
意訳.gs
実行する機能を定義する(何をやる機能か)
現在編集しているフォームを取得して
最初の質問をTextItemとして取得して
helloと回答し
フォームの回答を作成し
送信する




Latest post

Googleドライブのファイルを指定フォルダに移動したい - Move a file to a specific folder in Google Drive via Apps Script

Googleドライブのファイル移動を簡単にしたくて書いたコードです。 I wrote this code to make it easier to move files in Google Drive. 移動したいファイルURLと移動先のフォルダURLを入力して移動するWebアプ...