I am trying to develop an approval workflow for time requested off via google form. An add-on would solve this no problem but my company is weird about that stuff so I was trying to generate a script to perform this function. I'm getting so many errors in my doGet function I"m just about to give up. I've tried googling each individual error to see how I can fix it. I've tried seeing if there is a script that someone has already done but no luck. What I want is for the person to submit their request off form. An email be sent to the supervisor with a link to approve/deny the request then an email sent back to the original requester with their results. I forgot to add. This is the script I am plugging in to the google sheet that is attached to the google form not the form itself. The error that I seem to keep getting is "TypeError: Cannot read property "approval" from undefined"
function sendemail(e) < var email = e.values[1]; var supervisoremail = e.values[2]; var begindateabsent = e.values[3]; var enddateabsent = e.values[4]; var url = 'https://script.google.com/a/mesd.k12.or.us/macros/s/AKfycbwvm63UG8X9Wqdkt7yxUFKhvMXu58yvbeY2udJVJKmheIuagQlB/exec'; var approve = url + '&approval=true' + '&reply=' + email; var deny = url + '&approval=false' + '&reply=' + email; var html = "" + "Please review/
" + begindateabsent + ": " + enddateabsent + "
" + "Approve
" + "Deny
" + "" : MailApp.sendEmail("[email protected]", "Approval request", "What no html?", < htmlBody: html >); > function doGet(e) < var answer = (e.parameter.approval == 'true') ?'Your request has been approved' : "Your request has been denied"; MailApp.sendEmail(e.parameter.reply, "Your leave request", "Your supervisor said: " + answer); var app = UiApp.createApplication(); app.add(app.createHTML('An email was sent to ' + e.parameter.reply + 'saying: ' + answer + ' ')); return app; >
current error says my reply parameter on my doGet function is not defined.
Welcome. The UiApp method is deprecated instead you could use HTML Service. Please read developers.google.com/apps-script/guides/web.
Commented Aug 13, 2019 at 2:39Are you use that e.values[1] is returning a valid email address? Also check typos around deny (" replay ", " ? . : ")
Commented Aug 13, 2019 at 5:10Welcome. "reply parameter. is not defined." That does seem rather clear. I suggest you grab the Event objects that are being returned and trouble-shoot from there. JSON.stringify(e); is the way to go and there's an example in the documentation.