Form not emailing to helpdesk

19 views
Skip to first unread message

Carl G

unread,
Jun 18, 2019, 2:45:38 PM6/18/19
to Google Apps Script Community
function onFormSubmit(e) {
  var eventResponses = e.response.getItemResponses();
  var userEmail = e.response.getRespondentEmail();
  var responseUrl = e.response.getEditResponseUrl();
  
  try{
  var UserName = eventResponses[0].getResponse();
  var preapproved = eventResponses[1].getResponse(); 
  var notapproved = eventResponses[2].getResponse(); 
  }
  catch(error){}; 
  
  Logger.log(UserName);
  Logger.log(preapproved); 
  Logger.log(notapproved); 

  var helpdesk = 'help...@compxyz.com'; 
  var software = ''; 
  if(preapproved == null){ software = notapproved; }
  else{ software = preapproved; } 
  
  MailApp.sendEmail(helpdesk, UserName + ' put in a software request', UserName + " has put in a request for " + software + ", please see the request here:" + responseUrl), {
    name: "Software Request Form", 
    noReply: true
  };
}


Cant figure out why the google form wont send the request to our helpdesk system 

Alan Wells

unread,
Jun 18, 2019, 3:38:44 PM6/18/19
to Google Apps Script Community
You've got 5 parameters.  The most you can have is 4.  For readability and maintenance, use just one parameter which is an object, and put the subject and body into a variable:

var email = "helpdesk";
var subject = "UserName + ' put in a software request';
var body = " please see the request here:" + responseUrl;

var message = {
  to:email,
  subject: subject,
  body:body,

}

MailApp.sendEmail(message);
Reply all
Reply to author
Forward
0 new messages