我想从谷歌表单提交中调用用户电子表格功能来更新电子表格中的一些信息。
所有脚本都在同一个google驱动器上。
有办法吗?
我的Google表单中的代码:
function updateSheet() {
spreadsheet = SpreadsheetApp.openById('daedaeddea');
spreadsheet.myFunction();
}
function onOpen() {
var form = FormApp.openById('deadeadaedae');
ScriptApp.newTrigger('updateSheet')
.forForm(form)
.onFormSubmit()
.create();
}
答案 0 :(得分:0)
您绝对可以将Google表单与电子表格相关联。 Quickstart: Managing Responses for Google Forms中有关于如何使用onFormSubmit触发器执行此操作的示例。
这是一个片段:
function onFormSubmit(e) {
var user = {name: e.namedValues['Name'][0], email: e.namedValues['Email'][0]};
// Grab the session data again so that we can match it to the user's choices.
var response = [];
var values = SpreadsheetApp.getActive().getSheetByName('Conference Setup')
.getDataRange().getValues();
for (var i = 1; i < values.length; i++) {
var session = values[i];
var title = session[0];
var day = session[1].toLocaleDateString();
var time = session[2].toLocaleTimeString();
var timeslot = time + ' ' + day;
// For every selection in the response, find the matching timeslot and title
// in the spreadsheet and add the session data to the response array.
if (e.namedValues[timeslot] && e.namedValues[timeslot] == title) {
response.push(session);
}
}
sendInvites_(user, response);
sendDoc_(user, response);
}