I recently made a Google Apps Script that runs onSubmit of a Google form. It automatically emails the info captured in the form to the approving manager in an html format.
I’ve attempted to add additional workflow by including two buttons in the email – “Approve” and “Deny”. However, I am unable to attach a function to these buttons (e.g., the submit button would forward the email to X, etc).
I would appreciate if anyone could help me out with this – I haven’t been able to find/understand online solutions, and I fear I may be over my head in this. Below is my code:
function notfiy(e) {
var username = e.values[1].toString();
var requestfor = e.values[2].toString();
var location =e.values[3].toString();
var department = e.values[4].toString();
var phonenumb = e.values[5].toString();
var extension = e.values[6].toString();
var approver = e.values[7].toString();
var computer = e.values[8].toString();
var monitor = e.values[10].toString();
var accessories = e.values[12].toString();
var html =
'<body>' +
+'<h2>'+ username + ' has submitted a request to purchase equipment for ' + requestfor + ' </h2>' + '<br>' + '<br>' +
'Location: ' + location +
'<br> Department: ' + department +
'<br> Phone Number: ' + phonenumb +
'<br> Extension: ' + extension +
'<br> <br> The following materials have been requested for purchase: ' +
'<br> <br> Software: ' +
'<br> Computer: ' + computer +
'<br> Monitor: ' + monitor +
'<br> Computer Accessories: ' + accessories + '<br> <br> The ship to location for said materials is :' + '<br> <br> <br> <br>' +
'<input type="submit" value="Approve" />' + '<br>'+
'<input type="submit" value="Deny" />' +
'</body>';
MailApp.sendEmail(approver, "Equipment Request: " + username, 'No html body);', {htmlBody: html});
}
I’ve added a video tutorial about how to get this done:
https://sites.google.com/site/scriptsexamples/home/announcements/emailapprovalusinggooglescriptandaform