【问题标题】:Google Apps Script google.script.run.withSuccessHandler failingGoogle Apps 脚本 google.script.run.withSuccessHandler 失败
【发布时间】:2015-07-02 18:41:44
【问题描述】:

我有 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';
  }
}

这不起作用。有谁知道为什么这会失败?当第一个函数成功时调用的函数都只显示一个弹出窗口,告诉用户他们的响应已提交。

【问题讨论】:

    标签: javascript jquery google-apps-script


    【解决方案1】:

    来自 Google 文档:

    页面中的表单元素作为参数也是合法的,但它必须是函数的唯一参数。

    表单元素不能传递其他任何东西,它必须是唯一的参数。

    Google Documentation - google.script.run.function(parameter)

    【讨论】:

    • 我不知道这个。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 2021-06-08
    • 1970-01-01
    • 2021-08-02
    • 2018-10-21
    • 1970-01-01
    相关资源
    最近更新 更多