簡體   English   中英

在 Email 消息中獲取 Google Forms 響應

[英]Get Google Forms Responses in an Email Message

我寫信給您是因為我遇到了基於 Google 表單提交(或發送 GForm 時的新 GSheet 條目)的自動 email 腳本的問題。 流程簡述:

我有一個鏈接到 Data Studio 和 Power BI 儀表板的 Google 表單( 這里有一個類似的表單)。 根據進入電子表格的數據,forms 會自動使用破折號中的計算字段(日期、ActionID、代碼、ID、位置等)進行預填充,並且數據會進入破折號鏈接的電子表格[可能看起來像的示例] . 問題是,如果在檢查過程中發現錯誤,表格/電子郵件的副本也應發送給員工(可選,比他們高的人,以便雙方都知道詳細信息,而不僅僅是填寫的審計員-在表格中 – 只是選項)。 由於數據的敏感性,我無法使用任何可用的 GForms 附加組件。 審計員沒有對 Forms/Dashes 的編輯權限,並且通過 email 發送所有信息會花費太長時間。 我還創建了一個測試 Google 表單來演示它的外觀 總而言之,我正在尋找的是一個動態腳本,它還將獲取員工的公司 email(主管是可選的),當審計員提交表格時,表格的電子郵件/副本也會發送到上述人員。 我找不到任何與 GForms 相關的內容。

我以前使用過類似的腳本,但不要認為它是基於添加到電子表格[Example]的新行。 如果不可能實現這樣的目標,即使是電子表格輸入表格/電子郵件也會非常感激(基於表格中的“EmployeeEmail”的電子郵件+包括選定的列,如表中所示),盡管我擔心事情會出錯在一個有很多行的文件中。 我試圖找到類似的東西並發現了 2 個腳本,但我不知道如何使它們動態化:下面的第一個只是將消息發送到給定范圍內的電子郵件,它是 static(范圍)。

謝謝,它看起來不錯。 但我有兩個問題。 編輯:它總是需要虛擬 email('xxx@xxx.xxx'”,這意味着我(或其他人)會收到數百封電子郵件。我們能否以某種方式擺脫這一行或將其替換為表單發件人 email (我可以用表單發件人 email(谷歌表單自動添加電子郵件)/那些已經在第 2/3 列中的列替換現有列?

第二件事,如何將虛擬消息行連接到變量:var message = row.join('\n'); (當前添加第 n 行的值)

例如,我們能否以某種方式將 text join 替換為 eg

// Info from specific columns
var Date = lastRowValues[n][5]; //I don’t know how to grab last value from columns, it’s probably something like variable.getLastRow() + variable.getLastColumn() + Get values
var ID = lastRowValues[n][6];
var Code= lastRowValues[n][8];
var Action = lastRowValues[n][9];
var Location = lastRowValues[n][10];
var ErrorType = lastRowValues[n][11];

然后在留言中

// var = message = “You’ve made an error. Please find the details below.” +
“\n “ +
“\n Date of Action:  “ + Date + 
“\n ID:  “ + ID +
“\n Action Code:  “ Code +
“\n Type of Action:  “ + Action +
“\n Location:  “ + Location +
“\n Error Type:  “ + ErrorType  +

rest,如標題,可以保持不變。 我意識到只有數字很難閱讀。 有可能實現這個 output 嗎? 這就是現在的樣子

您可以在鏈接的電子表格中添加此代碼:

// this function will fires automatically 
// it grabs all data from the last row and send it via email

function send_email() {
  var row = SpreadsheetApp.getActive().getDataRange().getValues().pop();
  var message = row.join('\n');
  var subject = 'test subject';
  var address = 'xxx@xxx.xxx';
  GmailApp.sendEmail(address, subject, message);

  // additional emails

  var address2 = row[2];
  GmailApp.sendEmail(address2, subject, message);

  var address3 = row[3];
  GmailApp.sendEmail(address3, subject, message);

}


// this function should be run just once to install the trigger

function install_onFormSubmitTrigger() {
  var ss = SpreadsheetApp.getActive();
  ScriptApp.newTrigger('send_email').forSpreadsheet(ss).onFormSubmit().create();
}

每次提交表單時安裝觸發器后,表單中的所有數據(= 工作表最后一行的所有單元格)都將發送到xxx@xxx.xxx 以及來自單元格“C”和“D”的另外兩個地址。

根據需要隨意更改代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM