Learn-to-send-email-via-google-script-html-no-server: Undefined field in email body

Created on 11 Oct 2020  路  5Comments  路  Source: dwyl/learn-to-send-email-via-google-script-html-no-server

Hi! Thanks for this really useful script... I've used it twice, once perfectly. The other form has a small issue.

The first field it displays in the resulting email body is "Undefined undefined". The rest of the email is fine and accurately displays the data entered. I would guess it has something to do with how the Google Sheets doc is structured? Any ideas would be appreciated.

Most helpful comment

Thanks for the thoughts! I will do some poking around and will report back if I figure it out, in case it helps anyone else.

All 5 comments

Do you have an example of the form you could share? There's an example in the repo of one hosted on codepen. It could be a bug or something with looking up with the field isn't working, maybe the form elements have a mismatched name or element or something resulting in a lookup failing (which results in "undefined"?).

Sorry for my slow response - I forgot all about this! Here's the live version of the form. If you need a version on codepen, let me know.

Thanks!

I checked the form on that website. I started prepping the data to submit the form on the client, and this is the payload that was being generated: {"name":"test name","email":"[email protected]","message":"test","formDataNameOrder":"[\"name\",\"email\",\"message\"]","formGoogleSheetName":"responses","formGoogleSendEmail":"[email protected]"}

I don't see anything undefined there & nothing looks obviously wrong with the form to match what you are describing. Idk what your code on the server looks like, but maybe it is doing something funny?

Other oddities I noticed with the form that are unrelated:

  • it looks like the email sent to the server is our example one; maybe you are setting it on the server (safer); this could be our default behavior which is weird but that's not on you
  • the honeypot field is visible; if you add a display: none in the css then it won't be possible for users to fill it out, but bots often will.

Thanks for the thoughts! I will do some poking around and will report back if I figure it out, in case it helps anyone else.

If you have anything else to add for others in the future, we welcome it! Hopefully, you were able to figure it out. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EugeneFitzher picture EugeneFitzher  路  4Comments

austinjupiter picture austinjupiter  路  3Comments

joshiadvait8 picture joshiadvait8  路  3Comments

onurusluca picture onurusluca  路  4Comments

eleosa picture eleosa  路  4Comments