![](/img/trans.png)
[英]google.script.run.withSuccessHandler does not return value
[英]Google Apps Script google.script.run.withSuccessHandler failing
我有2个google.script.run.withSuccessHandler调用一个接一个地发生,当我尝试将两者结合起来时,它不起作用。 这是有效的代码,包含受影响的所有主要内容。
//These are in a javascript function which executes when a submit button is clicked.
google.script.run.withSuccessHandler(updateOutput).processForm(frmData);
google.script.run.withSuccessHandler(returnMessage).sendEmail(theData, titles);
//server functions
function processForm(theForm) {
try{
var fileBlob1 = theForm.resumeFile;
var fldrSssn = DriveApp.getFolderById('My Folder ID');
fldrSssn.createFile(fileBlob1);
return 'good';
}catch(e) {
}//End catch
}
function sendEmail(arr, titles) {
try {
//This function sends an email and edits a spreadsheet. Nothing is affected
return 'Request Submitted';
}
}
但是当我尝试将两者结合使用时,程序会识别出已单击提交按钮,但它不会超过google.script.run.withSuccessHandler命令。
//google.script.run.withSuccessHandler(updateOutput).processForm(frmData);
google.script.run.withSuccessHandler(returnMessage).sendEmail(theData, titles, frmData);
function sendEmail(arr, titles, theForm) {
try {
//Uploads the files
var fileBlob1 = theForm.resumeFile;
var fldrSssn = DriveApp.getFolderById('My Folder ID');
fldrSssn.createFile(fileBlob1);
var url1;
//Contains the rest of the code for sending an email and editing a spreadsheet.
return 'Request Submitted';
}
}
这不起作用。 有谁知道为什么会失败? 第一个函数成功时调用的函数都只显示一个弹出窗口,告诉用户他们的响应已提交。
来自Google文档:
页面中的表单元素也是合法的参数,但它必须是函数的唯一参数。
您不能使用表单元素传递任何其他内容,它必须是唯一的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.