Google Apps Script google.script.run.withSuccessHandler not working
I have 2 calls to google.script.run.withSuccessHandler that happen one after the other and when I try to combine the two it doesn't work. Here's the code that works, with all the main reasons involved.
//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 is clicked, but it doesn't navigate past the google.script.run.withSuccessHandler command.
//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? Functions that are called when the first functions succeed will only display a pop-up informing the user that their response has been sent.
+3
source to share