1

I'm doing a PWA using spreadsheet as storage. When I want to submit my info it works well on Web (Chrome, Safari, Opera, etc), it works too like PWA on android.

But when I add the app on Iphone/iPad, when I try to submit the info, it opens a page on safari and show me this error:

Script function not found: doGet.

Google script

    // spit out all the keys/values from the form in HTML for email
    // uses an array of keys if provided or the object to determine field order
    function formatMailBody(obj, order) {
    return result; // once the looping is done, `result` will be one long string to put in the email body
    }

    function doPost(e) {
    //operations with values from form
    record_data(e);}

    function record_data(e) {//operations}

And this is my HTML code:

    <form id="gform" class="pure-form pure-form-stacked" data-email="xxxxx@gmail.com" action="https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxxxx/exec" method="POST">
    //Some inputs

    <input type="hidden" id="de" name="de" value='nombre'> 
    <input type="hidden" id="tipopersona" name="tipopersona"> 
    <input type="hidden" id="correo" name="correo" > 
    </form>

I want to remove the doGet () error and execute the other code as it should or else know what is causing that error just in iOS PWA.

Alondra
  • 41
  • 4

1 Answers1

0

This question is answered in a prior Stack Overflow thread titled: Script function not found: doGet. That answer does not show the code for the solution to the problem, so I'll add that here in case someone else runs across this.

As shared in that answer, all Google Apps Script web application deployments must include a doGet function whether or not the script processes GET requests. I eliminated this error by rewriting the script with the doGet function added, and setting its return value as the doPost function with the event parameter passed to it. Below is a simplified example:

function doPost (e) {

    Logger.log(`POST method activated: ${e}`);   

    return ContentService.createTextOutput(JSON.stringify('doPost is working.'));
}

function doGet (e) {

    return doPost(e);    
}

The current Google Apps Script documentation for web applications does not seem to mention this requirement, but when doGet is added to a doPost script it will eliminate this particular error.

massif
  • 31
  • 3