简体   繁体   English

Google Apps脚本google.script.run.withSuccessHandler失败

[英]Google Apps Script google.script.run.withSuccessHandler failing

I have 2 google.script.run.withSuccessHandler calls that happen one after the other, and when I try to combine the two, it doesn't work. 我有2个google.script.run.withSuccessHandler调用一个接一个地发生,当我尝试将两者结合起来时,它不起作用。 Here is the code that works, with all major things that are affected. 这是有效的代码,包含受影响的所有主要内容。

//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';
  }
}

But when I try to combine the two, the program recognizes that the submit button has been clicked, but it doesn't move past the google.script.run.withSuccessHandler command. 但是当我尝试将两者结合使用时,程序会识别出已单击提交按钮,但它不会超过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';
  }
}

This does not work. 这不起作用。 Does anyone know why this fails? 有谁知道为什么会失败? The functions that are called when the first functions are successful both only display a popup telling the user that their response was submitted. 第一个函数成功时调用的函数都只显示一个弹出窗口,告诉用户他们的响应已提交。

From the Google documentation: 来自Google文档:

A form element within the page is also legal as a parameter, but it must be the function's only parameter. 页面中的表单元素也是合法的参数,但它必须是函数的唯一参数。

You can not pass anything else with a form element, it must be the only parameter. 您不能使用表单元素传递任何其他内容,它必须是唯一的参数。

Google Documentation - google.script.run.function(parameter) Google文档 - google.script.run.function(参数)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 google.script.run.withSuccessHandler 不返回值 - google.script.run.withSuccessHandler does not return value google.script.run.withSuccessHandler(function) 不返回数据 - google.script.run.withSuccessHandler(function) not returning data google.script.run.withSuccessHandler 可以返回区域吗? - Can google.script.run.withSuccessHandler return area? 有什么方法可以简化 google.script.run.withSuccessHandler 中来自 code.gs 的各种函数调用吗? Google Apps 脚本 - Is there any way to simplify various function calls from code.gs in a google.script.run.withSuccessHandler? Google Apps Script google.script.run.withSuccessHandler(onSuccess)。 onSuccess在构造函数中不起作用 - google.script.run.withSuccessHandler(onSuccess). onSuccess doesn't works inside constructor 如何结合谷歌应用程序脚本processForm,withSuccessHandler和withUserObject - how to combine google app script processForm, withSuccessHandler and withUserObject Google Apps脚本将参数传递给google.script.run - Google Apps Script passing parameter to google.script.run Google Apps Script 上的 google.script.run 问题 - google.script.run problem on Google Apps Script 用于创建 Google 日历活动的 Google Apps 脚本触发器失败 - Google Apps Script trigger to create Google Calendar events is failing Google Apps脚本无法运行功能? - Google Apps Script not able to run function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM