google apps script - Get username on form submission when form is embedded -
i have been modifying desk tutorial script found here:
https://developers.google.com/apps-script/articles/helpdesk_tutorial
since internal use only, removed "contact email" field , set form log username spreadsheet. i've edited formsubmitreply function compensate:
original:
function formsubmitreply(e) { var useremail = e.values[3]; mailapp.sendemail(useremail, "help desk ticket", "thanks submitting issue. \n\nwe'll start " + "working on possible. \n\nhelp desk", {name:"help desk"}); }
modified:
function formsubmitreply(e) { var useremail = e.user; mailapp.sendemail(useremail, "help desk ticket", "thanks submitting issue. \n\nwe'll start " + "working on possible. \n\nhelp desk", {name:"help desk"}); }
as can see, i've done change how useremail variable defined. when view live form , submit ticket, seems work.
however, after embedded form internal google site (our "intranet"), no longer works.
is there way need define useremail work when form embedded?
i tried this:
var useremail = sheet.getrange(lastrow, getcolindexbyname("username")).getvalue();
but had no luck. appreciated! i'm new @ , trying hack few things working properly.
cheers
the event apparently being constructed differently embedded form.
try:
var useremail = session.geteffectiveuser().getemail();
that independent of event, , should identify user running script.
Comments
Post a Comment