Persistent Issue: google.script.run returns 'undefined' despite successful server-side execution - [Apps Script Web App]

62 views
Skip to first unread message

Adrien CANTIN

unread,
Jul 29, 2025, 4:09:51 AMJul 29
to Google Apps Script Community

Dear Google Apps Script Community,

I am experiencing a very persistent and frustrating issue with a Google Apps Script Web App, and I've exhausted all standard troubleshooting steps. I would greatly appreciate any insights or suggestions.

Summary of the Problem: My web app, deployed from Google Apps Script, fails to receive the return value from server-side functions called via google.script.run. Specifically, the client-side JavaScript receives undefined or null for the response, even though the server-side function explicitly returns a valid JavaScript object/array and its execution logs confirm success. This prevents the dynamic generation of my form elements.

Detailed Description of Attempts and Observations:

  1. Function getFormDefinitionTest() (server-side, Code.gs):

    • This function is designed to read form definitions from a Google Sheet and return them as a JavaScript array of objects.

    • Crucially, when executed directly from the Apps Script editor, its Logger.log statements confirm that it successfully reads the Sheet, constructs the array, and that the return statement is reached with a valid JavaScript array. (Example log: [getFormDefinitionTest] Final definition built (size: 1): [{"name":"adrien","label":"nom","type":"TEXT",...}]).

    • The execution in the Apps Script logs is consistently marked as "Completed".

  2. google.script.run.getFormDefinitionTest() (client-side, Index.html):

    • The client-side JavaScript calls this function to get the form definition.

    • However, the await expression resolves to undefined (or null), as confirmed by client-side console.log statements (e.g., Response from getFormDefinitionTest: undefined).

    • This leads to client-side TypeError: Cannot read properties of undefined (reading 'formType') or "formDefinition is not iterable" errors, preventing the form from rendering.

  3. Troubleshooting Steps Already Taken (Repeatedly and Meticulously):

    • Code Verification: My code (both Code.gs and Index.html) has been thoroughly reviewed and is based on common, correct patterns for google.script.run and templating. It functions as expected in a simple, isolated test environment where getAppConfig was confirmed to return values.

    • ID/Name Verification: All Spreadsheet IDs, Sheet Names, and Folder IDs (FORM_DEFINITIONS_SPREADSHEET_ID, FORM_DEFINITION_SHEET_NAME, PHOTOS_FOLDER_ID) are verified as correct and exactly matching.

    • Deployment Resets: I have repeatedly and meticulously performed "hard resets" of deployments:

      • Deleting all existing web app deployments.

      • Creating brand new web app deployments.

      • Setting "Execute as" to "Me (my Google Account email)".

      • Setting "Who has access" to "Anyone".

      • Crucially, I have always accepted ALL authorization prompts during deployment.

    • New Project Migrations: I have created multiple entirely new Apps Script projects from scratch, copied the code into them, and deployed them as web apps. The issue persists across new projects.

    • Browser Environment: Always tested in fresh incognito/private browser windows to rule out local caching issues.

    • HTML Templating (for APP_CONFIG injection): I've also tried injecting APP_CONFIG variables directly into the Index.html template using <?= variable ?> (via template.variable = value in doGet), but this also failed to populate the variables correctly in Index.html, suggesting a templating issue or a deeper problem with the evaluate() method in this context.

Current Hypothesis: Given the above, my strong suspicion is that this is not a code bug, but rather an issue with my specific Google Account's Apps Script environment, a persistent caching problem at Google's infrastructure level, or a subtle authorization failure that doesn't manifest as a standard error but prevents the google.script.run return value from being serialized/deserialized correctly to the client.

Request for Help: Has anyone else encountered such a situation where google.script.run consistently returns undefined (or null) even when server-side logs show a successful return of a valid object? Are there any less common troubleshooting steps or diagnostic tools I might be missing? Or is this indicative of a problem requiring direct Google support?

Thank you for your time and any assistance you can provide.

Best regards,


"Ce message et toutes les pièces jointes (ci-après le "message") sont établis à l'intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l’expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. L'internet ne permettant pas d'assurer l'intégrité de ce message, nous déclinons toute responsabilité au titre de ce message, dans l’hypothèse où il aurait été modifié."

Hilario Rivera

unread,
Jul 30, 2025, 9:05:07 AMJul 30
to google-apps-sc...@googlegroups.com
Buenas Tarde a mi paso lo mismo y fue producto de una actualizacion de google para evitar inviltracion de persona no autorizadas para que tenia una grieta y debido a eso ya el flujo de mi proyecto no se comportaba como los primeros modulos que confeccione, he tenido que adactarme a la nueva modalidad y con ayuda de IA he podido sortear el tema.


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/22eea6f6-8786-46b5-a071-ca46684f69acn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages