0
我想创建一个包含图片上传字段的数据收集表单。我尝试了谷歌表格,它本身不支持文件上传,但我发现这个例子:Form and file upload with htmlService and app script not working使用Google Apps脚本的自定义表单的提交时间戳
我设法配置它与图片上传,但本地谷歌表格确实有电子表格响应时间戳列。
我想:
var timestamp = theForm.getTimestamp();
但没有工作......
我怎样才能得到响应时间戳?
代码摘录:
function processForm(theForm) {
var fileBlob = theForm.myFile;
var folder = DriveApp.getFolderById(folderId);
var doc = folder.createFile(fileBlob);
// Fill in response template
var template = HtmlService.createTemplateFromFile('Thanks.html');
var name = template.name = theForm.name;
var email = template.email = theForm.email;
var timestamp = template.timestamp = theForm.getTimestamp();
// Record submission in spreadsheet
var sheet = SpreadsheetApp.openById(submissionSSKey).getSheets()[0];
var lastRow = sheet.getLastRow();
var targetRange = sheet.getRange(lastRow+1, 1, 1, 5).setValues([[timestamp,name,department,message,email,fileUrl]]);
// Return HTML text for display in page.
return template.evaluate().getContent();
}
工作,谢谢。但是,这不是客户端时间戳吗? – Silva 2014-10-04 19:36:57
不,.gs Google Apps脚本文件在服务器上进行处理和执行,而不是在客户端的浏览器中执行。所以时间戳将是服务器时间戳。您应确保您的GAS项目在菜单文件 - >项目属性下_Info_选项卡上选择了正确的时区。 – azawaza 2014-10-06 18:32:21
哦,谢谢你的信息。我没有使用GAS的经验。谢谢! – Silva 2014-10-07 20:59:32