學員可以從這裡複製
/*============================================ 試算表收到表單回覆函數 時間戳記 說明 預填連結 轉換後的連結 1 2 3 4 ============================================*/ function onFormSubmit(e) { // 取得工作表 let ws = e.range.getSheet(); // 取得新增記錄的行號 let rowIndex = e.range.getRow(); // 預填連結 的陣列索引 let originalIndex = 2; // 取得資料 let originalURL = ws.getRange(rowIndex, 1, 1, ws.getLastColumn()).getValues()[0][originalIndex]; // 轉換資料 let replacedURL = replaceURL(originalURL); // 轉換後的連結 的 工作表欄索引 let index = 4; // 寫入資料 ws.getRange(rowIndex, index).setValue(replacedURL); } /*============================================ 替換網址 ============================================*/ function replaceURL(originalURL) { // 進行替換 let replacedURL = originalURL.replace("viewform", "formResponse").replace("usp=pp_url", "submit=Submit"); return replacedURL; }