为了检索
我看过谷歌应用程序的脚本how-tos,但对于像我这样的新手来说,这并不是不言自明的。
我也尝试过根据我的需要调整在线视频脚本,但它们总是会返回错误。
我需要帮助如何输入下面的代码,以便它在表单响应电子表格上生成一个链接,显示完整的表单和用户提交的答案。
下面是我在谷歌应用程序脚本上找到的代码,但我不知道如何输入。
CCD_ 1基于该表单响应中的答案生成其中预先填充了答案的表单的URL。
function addFormResponseUrl(e) {
// Get the Form response URL and add it to the Google Spreadsheet
var responseUrl = formResponse.getEditResponseUrl();
var row = e.range.getRow(1);
var responseColumn = 1; // Column where the response URL is recorded.
responseSheet.getRange(row, responseColumn).setValue(responseUrl);
}
为了检索EditResponseUrl
并将其粘贴到表单响应旁边的目标电子表格中:
- 编写一个函数,检索最新的表单响应并将相应的
EditResponseUrl
粘贴到目标电子表格中 - 将脚本绑定到destination电子表格
- 为函数附加一个可安装的FormSubmit触发器
示例脚本:
function addFormResponseUrl(e) {
//open the form by its id
var form =FormApp.openById("XXX");
var formResponses = form.getResponses();
// get the latest form response
var lastResponse = formResponses[formResponses.length-1];
//get the response URL
var responseUrl = lastResponse.getEditResponseUrl();
// get the sheet where the responses have been stored
var responseSheet = SpreadsheetApp.getActive().getActiveSheet();
//get the row where the last response has been stored
var row = e.range.getRow();
// Safe the response Url in the first free column after the form responses.
var responseColumn = e.values.length+1;
responseSheet.getRange(row, responseColumn).setValue(responseUrl);
}