Help Please - Google App Script Trigger isn't working

214 views
Skip to first unread message

DoverSeed Google Workspace Admin

unread,
Mar 4, 2024, 2:38:16 AM3/4/24
to Google Apps Script Community
Hello!  

I am new to using Google App Script and have spent the better part of the day trying to get what I thought would be a simple script working. :(

Scenario: I have a Squarespace form configured to store submissions in a Google Sheet on the submit button.  I went into the Google Sheet, went to Extensions and added a Google script to send an acknowledgement email upon submission of the Squarespace form.  Additionally, I setup a Trigger for 'onformsubmit'.  Below are screenshots of the error that I'm receiving and the trigger setup.

Problem:  Google Sheet is getting updated as expected (see screenshot below) but I am not receiving the acknowledgement email as expected.  I'm receiving the following error:
TypeError: Cannot read properties of undefined (reading 'namedValues')
Code.gs:3

If anyone has experienced this issue and can help me I would greatly appreciate it!

Thanks in advance for your help!

Denise

Script error.png
Trigger setup.png
Google Sheet.png

Ed Sambuco

unread,
Mar 4, 2024, 8:51:34 AM3/4/24
to google-apps-sc...@googlegroups.com
You need to trigger the email from the spreadsheet, not the formsubmit.

--
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 on the web visit https://groups.google.com/d/msgid/google-apps-script-community/619e932f-d95c-4cde-a749-611d85301c56n%40googlegroups.com.

DoverSeed Google Workspace Admin

unread,
Mar 4, 2024, 9:16:16 AM3/4/24
to google-apps-sc...@googlegroups.com
Good morning, Ed,

Thank you for your response.  Are you saying the script itself is ok and that I just need to change the Trigger setup?  When I attempt to change the trigger setup for which function to run, the only option is OnFormSubmit.  When I try to change "select event type" my options include the following:

image.png

You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/8yjMlb8P8MU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CAANZsGNDdkto%2Bt8JYMLFE%2BsNkcai-C8%3DSpfk%2BGO%3Dd1ijD3nJ3g%40mail.gmail.com.

Ed Sambuco

unread,
Mar 5, 2024, 10:30:19 AM3/5/24
to google-apps-sc...@googlegroups.com
No. The email should come from a second trigger script bound to the spreadsheet.  Use values from the new spreadsheet to populate the email.

Ed Sambuco

unread,
Mar 6, 2024, 8:01:55 AM3/6/24
to google-apps-sc...@googlegroups.com
Sorry for delayI am dealing with sick relatives and have been distracted.

Not sure if I gave the best answer, but you have to be careful about the event object.  Nanedvalues is not an event object field from a spreadsheet.  You are specifying the spreadsheet as the starting event to kick off the email. 

My lapto is currently in bad shape so I can’ check this out.  Try changing starting event in the onformsubmit trigger.

DoverSeed Google Workspace Admin

unread,
Mar 6, 2024, 10:30:44 AM3/6/24
to google-apps-sc...@googlegroups.com
Thanks Ed.  I'm sorry to hear about your relatives.  I hope they get better soon!  

I have decided to change my approach and use a time driven function which I did get to work, so I'm all set for now.

Take care, 
Denise

Reply all
Reply to author
Forward
0 new messages