Giter VIP home page Giter VIP logo

formresponse-to-document's Introduction

FormResponse-To-Document

使用 Apps Script,當送出 Google 表單回應時,就會用該回應資料輸出一個文件!

使用

請參照我的這篇文章使用~ 記得要設定觸發器嘿!

用途

  1. 取得 form submit 事件的資料
  2. 從模板複製新檔案
  3. 將資料塞到模板檔案裡

formresponse-to-document's People

Contributors

harryuan65 avatar

Stargazers

jell Wu avatar

Watchers

 avatar

formresponse-to-document's Issues

文件內容發送Line notify

老師請問是否可以在寫入文件後取得文件的雲端連結利用line notify將指定欄位的內容以及連結發送到手機上,我現在知道如何發送回應內容到line notify 也知道如何寫入文件,希望兩個能夠合在一起,謝謝老師~

我在現在這個版本沒辦法用event相關語法

我沒有學過程式語法,所以搜尋了google app script的功能,找到老師在medium的文章,但表單、試算表、文件、資料夾都做好了,貼上老師的程式碼,改成我的檔案的id,但第一次執行他說event語法沒有定義,而且好像也無法去跑出蒐集的資料和欄位,所以我重新找2023年的資料然後跟chatgpt多次溝通,得到可以用的程式碼.gs

  • 我詢問chatgpt的問題:

我想請你寫一份程式碼套用在google app script中,我有三份檔案,一份是表單產生的試算表回應,一份是同意書範本,一份是收集同意書的資料夾,我給你檔案id如下,從試算表最下面一列取得表單最新資料,然後複製同意書範本,取代同意書範本內容。
表單問題第一題開始依序回答填寫人、聯絡email、想說的話,並且會自動擷取填寫時間到試算表中(我不確定有沒有獲取時間戳記的相關語法),範本要修改的內容依序是{{name}}、{{email}}、{{message}}、{{timestamp}}。如果你不熟悉google app script語法,可以參照下列網站: https://developers.google.com/apps-script?hl=zh-tw

表單產生試算表:
"1ADovqmsNwYQ0YXU9z_ugejNZ3V0W5pjqoy4M7mugIqE"

同意書範本:
"1fY_7wZGFjDmjZsBOt9BkTp1DsFS4a14cXwITpJut1Ao"

收集同意書的資料夾:
"1KOLtwHQJ7u1DN_ZsyCTIxywVcd-kVKi1"

每個段落視情況幫我加入這些解釋:
// 獲取試算表和工作表

// 取得最後一行的資料

// 打開模板文件

// 打開輸出資料夾

// 複製一份模板文件到輸出資料夾

// 打開剛剛複製出來的新檔案

// 將資料塞到對應內容上面

  • 經過幾次來回修正時間戳記的格式,請他照著步驟編輯新的檔案,不要動到範本,然後一樣設定觸發條件就可以運行了。程式碼如下:

NewEditFunction() {
// 獲取試算表和工作表
var spreadsheet = SpreadsheetApp.openById("1ADovqmsNwYQ0YXU9z_ugejNZ3V0W5pjqoy4M7mugIqE");
var sheet = spreadsheet.getSheetByName("表單回應 1");

// 取得最後一行的資料
var lastRow = sheet.getLastRow();
var formData = sheet.getRange(lastRow, 1, 1, sheet.getLastColumn()).getValues()[0];

var name = formData[1];
var email = formData[2];
var message = formData[3];

// 取得時間戳記
var timestamp = Utilities.formatDate(new Date(), "GMT+8", "yyyy/MM/dd");

// 打開同意書範本文件
var templateFile = DriveApp.getFileById("1fY_7wZGFjDmjZsBOt9BkTp1DsFS4a14cXwITpJut1Ao");

// 打開收集同意書的資料夾
var folder = DriveApp.getFolderById("1KOLtwHQJ7u1DN_ZsyCTIxywVcd-kVKi1");

// 複製一份同意書範本文件到收集資料夾
var copy = templateFile.makeCopy(name + "同意書_" + timestamp, folder);

// 打開剛剛複製出來的新檔案
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();

// 將資料塞到對應內容上面
body.replaceText("{{name}}", name);
body.replaceText("{{email}}", email);
body.replaceText("{{message}}", message);
body.replaceText("{{timestamp}}", timestamp);

doc.saveAndClose();
`}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.