Learn-to-send-email-via-google-script-html-no-server: Script function not found: doGet

Created on 30 Mar 2017  路  9Comments  路  Source: dwyl/learn-to-send-email-via-google-script-html-no-server

Sorry, I am trying to teach myself basic HTML while making a website for my wedding - my knowledge started at basically zero so apologies if this is really obvious.

I've followed these instructions exactly, and when I test the code I get the error: "Script function not found: doGet". A bit of google searching seems to suggest that I can't create a webapp without a doGet, but your code doesn't have one. What should I do?

Thanks

Most helpful comment

I had the same issue.

Make sure that you include method="POST in

<form id="gform" method="POST" class="pure-form pure-form-stacked" action="www.links-to your-script.com">

All 9 comments

Could you please include a minimal, working, verifiable example that reproduces your problem? Feel free to explain which steps you walked through, highlight any changes to the code you made. For example, see https://stackoverflow.com/help/mcve

You can host it on your own site, GitHubPages, or sites like CodePen. And include a link to your Google Spreadsheet, if you can, so we can take a look at what is set up.

Did you follow step 5) exactly? In the image, it shows the permissions set to "anyone, even anonymous", and if this is not set right then it cannot work. The Google Script should have a function doGet that should run when you send it the form data.

I had the same issue.

Make sure that you include method="POST in

<form id="gform" method="POST" class="pure-form pure-form-stacked" action="www.links-to your-script.com">

Same issue for me too. This happens when you "Test web app for your latest code"

@joshrio I already have POST set as the HTML form method yet it's still prompting me with the doGet error

Does anyone have a working example to share that reproduces this issue?

It is kind of hard to debug since I cannot reproduce it. If you are using older browsers, that may affect the Javascript functionality, but any evergreen browser should work fine. There are _many_ ways that altering code or not adding something may break the script. Check the console to see if error messages appear. You should not be forwarded to a new page if you are using the custom Javascript on here as well, though if you aren't it may still submit and send you to a new page with the AJAX result.

I'm running the latest Chrome browser here.

However I have found the solution!

https://stackoverflow.com/questions/22272308/script-function-not-found-doget?rq=1

So added:
function doGet(e) { doPost(e) }

Ahhh! I see, the "Test web app..." button is probably only using a doGet. I have never used that functionality before (and I thought you were referring to a step, whoops).

Generally, you would want to submit form data with POST, not GET:

https://www.w3schools.com/tags/ref_httpmethods.asp

http://www.diffen.com/difference/GET-vs-POST-HTTP-Requests

Okay so this is probably a major cause of concern for my client but... the issue I was having was actually unrelated to this. I thought it was related because one of my debugging steps was to visit the URL to the web app - that's where I saw the doGet error and yes, you're right that shouldn't be an issue, it's only saying that because if you visit the link via a browser you're trying to use an entry point via a get request - which is evidently not defined.

Rather embarrassingly tho, the actual problem was: My clients email inbox wasn't receiving any emails at all. The cause of this was the hosting procedure. The domain was bought via Google admin (and connected to a partner domain site) but when I hosted the site on an independent vendor, I had to configure the name servers of the domain to point to the hosting sites name servers. Turns out, that left the mail that was initially being directed to Gmail servers, to be disconnected! So, my client has lost out on 10 days of emails to their inbox :/ Fixed now but something new learnt at a very costly price

Probably safe to close this issue now, since the doGet thing is clarified now as not being a problem

Thanks for the update, @mkhalila ! Glad you were able to track down the issue and work it out.

This common error can be pulled into a FAQ, which we hope to put together shortly.

Was this page helpful?
0 / 5 - 0 ratings