[英]Google script creates two spreadsheets instead of one
Good day! 美好的一天!
My script processing form submission on spreadsheet side. 我在电子表格一侧处理表单提交表单。
function onSubmit(e) {
var obj, scriptProperties, counter;
var prop = 'submissions';
obj = raw_answer_to_raw_obj(e.values);//this function pack answer into object
scriptProperties = PropertiesService.getScriptProperties();
counter = scriptProperties.getProperty(prop);
if (counter==null) counter = 0;
counter++;
scriptProperties.setProperty(prop, counter);
new_answer_processing(obj);
}
with calls at the end main processing function wich I can test emulating the obj. 最后主要处理函数的调用,我可以测试模拟obj。 new_answer_processing() function calls function create_ss_in_folder only once:
new_answer_processing()函数只调用一次函数create_ss_in_folder:
function create_ss_in_folder(folder_name, name, root) {
var ss, id, file, folder;
Logger.log('creating spreadsheet...');
ss = SpreadsheetApp.create(name);
id = ss.getId();
Logger.log('ss id: ' + id);
file = DriveApp.getFileById(id);
var folder = get_folder_by_name(folder_name, root);
folder.addFile(file);
DriveApp.getRootFolder().removeFile(file);
return ss;
}
Singleton of call proved by logfile and call counter submissions (you can watch video http://youtu.be/DTawqYPa44A ) but in fact it's make two spreadsheets. 通过logfile和呼叫计数器提交证明了调用单例(你可以观看视频http://youtu.be/DTawqYPa44A ),但实际上它是两个电子表格。
This error occurs not each time when the form submits and never if I emulate submission by script. 每次表单提交时都不会发生此错误,如果我通过脚本模拟提交,则不会发生此错误。 Is it a reason for issue or I miss something?
这是问题的原因还是我错过了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.