tag:blogger.com,1999:blog-8904812486779116235.post3012690959132403691..comments2024-03-24T13:34:43.852-04:00Comments on Blogger Xpertise: Tip: Making a Google Doc submission form email you the resultsDavid Kutcherhttp://www.blogger.com/profile/10595261225719571066noreply@blogger.comBlogger151125tag:blogger.com,1999:blog-8904812486779116235.post-9781834330547558142013-09-12T16:39:08.149-04:002013-09-12T16:39:08.149-04:00Great script - thank you! I don't know if you...Great script - thank you! I don't know if you can help, but I have had to link my form to new spreadsheets so that the code works. The problem I'm running into now is that each iteration of the code (/spreadsheet) runs. In other words, I get 3 emails after each form submission. Any ideas how this can be fixed? Either way, I'm appreciative that you've put this out there. 3 emails is better than none!Katienoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-23287343414419992802013-09-09T17:15:04.631-04:002013-09-09T17:15:04.631-04:00Hi. I used this script and got the "undefined...Hi. I used this script and got the "undefined" error. Adding the check for undefined vars as below fixed it. Now if the form field is empty, is is also listed empty in the submission email. Something like "FieldData = \n\n"<br /><br /> if (typeof e.values[i] != 'undefined'){<br /><br /> message += headers[i] + ' = '+ e.values[i].toString() + '\n\n'; <br /><br /> }<br /><br /><br /><br />this is a quite simple fix for my case were there is one field on my form that is not required. After this. your script is very great blessing. Thank you for sharing.Netavarka Suraksanoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-86376514497975936392013-09-04T10:58:37.795-04:002013-09-04T10:58:37.795-04:00For starters, remove #gid=0 from your docKey value...For starters, remove #gid=0 from your docKey value.David Kutcherhttp://www.confluentforms.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-46216173968790207162013-09-04T10:56:04.624-04:002013-09-04T10:56:04.624-04:00@fmiboy it works, we fixed @Michael Radie's is...@fmiboy it works, we fixed @Michael Radie's issue and it wasn't an issue with the code. As I indicated in the "Common Issues", it is most likely your form or the variable values that you are including.David Kutcherhttp://www.confluentforms.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-55222712785191941142013-09-04T04:57:15.532-04:002013-09-04T04:57:15.532-04:00I get same error. I think .toString() property is ...I get same error. I think .toString() property is not supported anymore, or something else is missing. Could you guys check the issue and if there is workaround for break line replacement? Thanks!fmiboynoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-84937103131784853452013-08-28T23:07:44.202-04:002013-08-28T23:07:44.202-04:00Michael, check out this video, the script will be ...Michael, check out this video, the script will be referenced here and you can see the walk through: http://www.youtube.com/watch?v=z6klwUxRwQIMike Pattersonhttp://mpattyfly.tumblr.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-3537428572657045252013-08-21T09:46:13.376-04:002013-08-21T09:46:13.376-04:00call or email us; the script works "in genera...call or email us; the script works "in general" but specifics oddities are usually the culprit.David Kutcherhttp://www.confluentforms.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-91591612910656536442013-08-21T09:39:57.926-04:002013-08-21T09:39:57.926-04:00Im getting error:
TypeError: Cannot read property...Im getting error:<br /><br />TypeError: Cannot read property "values" from undefined. (line 39, file "Code")<br /><br /> var message = "Sales Lead";<br /><br /> for(var i in headers) {<br /><br /> message += headers[i] + ' = '+ e.values[i].toString() + '\n\n';Michael Radienoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-35548637496729653042013-08-21T08:41:16.090-04:002013-08-21T08:41:16.090-04:00Can you send me link to the code that worked for y...Can you send me link to the code that worked for you, My team is stuck and I'm at witts end.Michael Radienoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-89863994931421945012013-08-07T14:46:40.646-04:002013-08-07T14:46:40.646-04:00THANK YOU.THANK YOU.Alex Westlundnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-10923789803387232602013-08-05T23:34:14.082-04:002013-08-05T23:34:14.082-04:00Getting a message read: Cannot read property &quo...Getting a message read: Cannot read property "namedvalues" from undefined. Checked on it several times, not sure where is the problem...Here is the code:<br /><br /><br />function sendFormByEmail(e) {<br /> var emailSubject = "Regal Daily Work Report Submission"; <br /> <br /> // Set with your email address or a comma-separated list of email addresses.<br /> var yourEmail = "shufen@regaltravel.com";<br /> <br /> // Set with your spreadsheet's key, found in the URL when viewing your spreadsheet.<br /> var docKey = "0ApJkHurvn3aidE1icWhaTnc3RzhYVS10clRwak1CbGc#gid=0";<br /> <br /> // If you want the script to auto send to all of the spreadsheet's editors, set this value as 1.<br /> // Otherwise set to 0 and it will send to the yourEmail values.<br /> var useEditors = 0;<br /> <br /> // Have you added columns that are not being used in your form? If so, set this value to <br /> // the NUMBER of the last column that is used in your form.<br /> // for example, Column C is the number 3<br /> var extraColumns = 0;<br /><br /><br /> if (useEditors) {<br /> var editors = DocsList.getFileById(docKey).getEditors();<br /> if (editors) { <br /> var notify = editors.join(',');<br /> } else var notify = yourEmail;<br /> } else {<br /> var notify = yourEmail;<br /> }<br /><br /><br /> // The variable e holds all the submission values in an array.<br /> // Loop through the array and append values to the body.<br /> <br /> var s = SpreadsheetApp.getActive().getSheetByName("Responses");<br /> var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];<br /> <br /> var message = "";<br /> for(var i in headers) {<br /> message += headers[i] + ' = '+ e.namedvalues[headers[i]].toString() + '\n\n'; <br /> }<br /><br /><br /> MailApp.sendEmail(notify, emailSubject, message); <br />}susannoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-88561342695704141442013-08-01T16:12:17.756-04:002013-08-01T16:12:17.756-04:00I renamed my sheet and took out the spaces, still ...I renamed my sheet and took out the spaces, still getting the same error. That and now I've broken the link that about 200 people have to register issues. Sure hope I can make this work to make this worthwhile.<br />Thanks for the quick response.Randy Bachnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-67903300608940394832013-08-01T15:55:39.583-04:002013-08-01T15:55:39.583-04:00Give "common issue #2" a try.Give "common issue #2" a try.David Kutcherhttp://www.confluentforms.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-85331573525375033612013-08-01T15:52:05.822-04:002013-08-01T15:52:05.822-04:00I have tried to make this script work but keep get...I have tried to make this script work but keep getting the same error on one of two lines, either 33 or 34.<br /><br />The error is as follows:<br /><br />TypeError: Cannot call method "getRange" of null. (line 33, file "Code")<br /><br />Here is the code:<br /><br />function sendFormByEmail(e) {<br /><br /> var emailSubject = "Google Docs Form Submission"; <br /><br /> <br /><br /> // Set with your email address or a comma-separated list of email addresses.<br /><br /> var yourEmail = "Randy.Bach@Boydgroup.com";<br /><br /> <br /><br /> // Set with your spreadsheet's key, found in the URL when viewing your spreadsheet.<br /><br /> var docKey = "7QYQW5jFgqctwlrfdVbQ";<br /><br /> <br /><br /> // If you want the script to auto send to all of the spreadsheet's editors, set this value as 1.<br /><br /> // Otherwise set to 0 and it will send to the yourEmail values.<br /><br /> var useEditors = 0;<br /><br /> <br /><br /> // Have you added columns that are not being used in your form? If so, set this value to <br /><br /> // the NUMBER of the last column that is used in your form.<br /><br /> // for example, Column C is the number 3<br /><br /> var extraColumns = 8;<br /><br /> if (useEditors) {<br /><br /> var editors = DocsList.getFileById(docKey).getEditors();<br /><br /> if (editors) { <br /><br /> var notify = editors.join(',');<br /><br /> } else var notify = yourEmail;<br /><br /> } else {<br /><br /> var notify = yourEmail;<br /><br /> }<br /><br /> // The variable e holds all the submission values in an array.<br /><br /> // Loop through the array and append values to the body.<br /><br /> <br /><br /> var s = SpreadsheetApp.getActive().getSheetByName("Avaya Phone System Issue Log");<br /><br /> if (extraColumns){<br /><br /> var headers = s.getRange(1,1,1,extraColumns).getValues()[0];<br /><br /> } else var headers = s.getRange(1,1,1,8).getValues()[0];<br /><br /> <br /><br /> var message = "";<br /><br /> for(var i in headers) {<br /><br /> message += headers[i] + ' = '+ e.values[i].toString() + '\n\n'; <br /><br /> }<br /><br /> MailApp.sendEmail(notify, emailSubject, message); <br /><br />}<br /><br />Any help would be appreciated, I love the concept and would like to see this work.<br />Thanks<br />RandyRandy Bachnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-17647273480315435992013-07-31T06:14:14.168-04:002013-07-31T06:14:14.168-04:00Yes, it is the most up to date and it does work. P...Yes, it is the most up to date and it does work. Please contact us if you'd like/need personal attention!David Kutcherhttp://www.confluentforms.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-25710127204889123502013-07-30T19:34:22.530-04:002013-07-30T19:34:22.530-04:00David, have had a hell of a time with this script ...David, have had a hell of a time with this script with numerous errors:<br />#1 - Can you confirm that the final version of the script is here: http://pastie.org/6499318<br /><br />#2 - I am constantly getting the "TypeError: Cannot call method "getSheetByName" of null. (line 31, file "Code")" even though the sheet name and name in the script are the same<br /><br /><br /><br />#3 When I try to play and test the code from the Script itself it gives me the attached error<br /><br /><br />Please help, I desperately need to get this thing working for my team at work!Mike Pattersonhttp://mpattyfly.tumblr.com/noreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-67366937142191252342013-07-18T12:51:19.184-04:002013-07-18T12:51:19.184-04:00I am having issues with the GetSheet command. My ...I am having issues with the GetSheet command. My code is below and I would love some help.<br /><br />function sendFormByEmail(e) {<br /><br /> var emailSubject = "Customer Load Request Submission"; <br /><br /> <br /><br /> // Set with your email address or a comma-separated list of email addresses.<br /><br /> var yourEmail = "ptadamson@gmail.com, paul@reptiledog.com";<br /><br /> <br /><br /> // Set with your spreadsheet's key, found in the URL when viewing your spreadsheet.<br /><br /> var docKey = "0AnKhRjNvhGbRdHFjVUZuam9ISzByb2RfM2w4elYwYWc#";<br /><br /> <br /><br /> // If you want the script to auto send to all of the spreadsheet's editors, set this value as 1.<br /><br /> // Otherwise set to 0 and it will send to the yourEmail values.<br /><br /> var useEditors = 0;<br /><br /> <br /><br /> // Have you added columns that are not being used in your form? If so, set this value to <br /><br /> // the NUMBER of the last column that is used in your form.<br /><br /> // for example, Column C is the number 3<br /><br /> var extraColumns = 11;<br /><br /> if (useEditors) {<br /><br /> var editors = DocsList.getFileById(docKey).getEditors();<br /><br /> if (editors) { <br /><br /> var notify = editors.join(',');<br /><br /> } else var notify = yourEmail;<br /><br /> } else {<br /><br /> var notify = yourEmail;<br /><br /> }<br /><br /> // The variable e holds all the submission values in an array.<br /><br /> // Loop through the array and append values to the body.<br /><br /> <br /><br /> var s = SpreadsheetApp.getActive().getSheetByName("Sheet1");<br /><br /> if (extraColumns){<br /><br /> var headers = s.getRange(1,1,1).getValues()[0];<br /><br /> } else var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];<br /><br /> <br /><br /> var message = "";<br /><br /> for(var i in headers) {<br /><br /> message += headers[i] + ' = '+ e.values[i].toString() + '\n\n'; <br /><br /> }<br /><br /> MailApp.sendEmail(notify, emailSubject, message); <br /><br />}Padamsonnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-61218931773276180382013-07-09T11:54:54.682-04:002013-07-09T11:54:54.682-04:00David, I am trying to set this up and getting an e...David, I am trying to set this up and getting an error on line 38. I have some fields that are not required, and therefore blank. Is this the issue?<br /><br />Details:<br />StartFunctionError MessageTriggerEnd7/9/13 11:50 AMsendFormByEmailTypeError: Cannot call method "toString" of undefined. (line 38, file "Code")formSubmit7/9/13 11:50 AMTom Smithnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-56321014275625903212013-06-20T09:48:51.210-04:002013-06-20T09:48:51.210-04:00I keep getting this error when I run: TypeError: C...I keep getting this error when I run: TypeError: Cannot call method "getSheetByName" of null. (line 31, file "Code") I have the sheet name without spaces as per the current issues suggestion.Master Jedinoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-82039514423631212532013-06-13T16:23:49.779-04:002013-06-13T16:23:49.779-04:00Very useful, thank you. Saved me lots of time and...Very useful, thank you. Saved me lots of time and headache!astimsonnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-54671609882711164492013-06-10T04:41:00.418-04:002013-06-10T04:41:00.418-04:00I also got the same problem.
TypeError: Cannot re...I also got the same problem.<br /><br />TypeError: Cannot read property "values" from undefined. (line 38, file "Code")<br /><br />Here's my code:<br /><br />function sendFormByEmail(e) {<br /><br /> var emailSubject = "Google Docs Form Submission"; <br /><br /> <br /><br /> // Set with your email address or a comma-separated list of email addresses.<br /><br /> var yourEmail = "MYEMAILADDRESS";<br /><br /> <br /><br /> // Set with your spreadsheet's key, found in the URL when viewing your spreadsheet.<br /><br /> var docKey = "0Ao8VO3aUvVFudGxMTnZfb1VNOU5uWDRuUko1amRaRFE";<br /><br /> <br /><br /> // If you want the script to auto send to all of the spreadsheet's editors, set this value as 1.<br /><br /> // Otherwise set to 0 and it will send to the yourEmail values.<br /><br /> var useEditors = 1;<br /><br /> <br /><br /> // Have you added columns that are not being used in your form? If so, set this value to <br /><br /> // the NUMBER of the last column that is used in your form.<br /><br /> // for example, Column C is the number 3<br /><br /> var extraColumns = 0;<br /><br /> if (useEditors) {<br /><br /> var editors = DocsList.getFileById(docKey).getEditors();<br /><br /> if (editors) { <br /><br /> var notify = editors.join(',');<br /><br /> } else var notify = yourEmail;<br /><br /> } else {<br /><br /> var notify = yourEmail;<br /><br /> }<br /><br /> // The variable e holds all the submission values in an array.<br /><br /> // Loop through the array and append values to the body.<br /><br /> <br /><br /> var s = SpreadsheetApp.getActive().getSheetByName("FormResponses");<br /><br /> if (extraColumns){<br /><br /> var headers = s.getRange(1,1,1,extraColumns).getValues()[0];<br /><br /> } else var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];<br /><br /> <br /><br /> var message = "";<br /><br /> for(var i in headers) {<br /><br /> message += headers[i] + ' = '+ e.values[i].toString() + '\n\n'; <br /><br /> }<br /><br /> MailApp.sendEmail(notify, emailSubject, message); <br /><br />}<br /><br /><br /><br /><br /><br />Thanks for your help!Lisanoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-75685126667135934202013-06-04T00:06:38.346-04:002013-06-04T00:06:38.346-04:00No, when I run the code. I only ran the code when ...No, when I run the code. I only ran the code when I tested the form+code and it didn't work. <br /><br />This is my code, this is a problem showing up in the comments happening every where you look up this method. Here's the code I've been using:<br /><br />function sendFormByEmail(e) <br /><br />{ <br /><br /> // Remember to replace XYZ with your own email address<br /><br /> var email = "nadia@nadiachaudhry.com"; <br /><br /> // Optional but change the following variable<br /><br /> // to have a custom subject for Google Docs emails<br /><br /> var subject = "Google Docs Form Submitted"; <br /><br /> // The variable e holds all the form values in an array.<br /><br /> // Loop through the array and append values to the body.<br /><br /> var s = SpreadsheetApp.getActiveSheet();<br /><br /> var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0]; <br /><br /> var message = ""; <br /><br /> // Credit to Henrique Abreu for fixing the sort order<br /><br /> for(var i in headers)<br /><br /> message += headers[i] + ' = '+ e.namedValues[headers[i]].toString() + "\n\n"; <br /><br /> // This is the MailApp service of Google Apps Script<br /><br /> // that sends the email. You can also use GmailApp here.<br /><br /> MailApp.sendEmail(email, subject, message); <br /><br /> // Watch the following video for details<br /><br /> // http://youtu.be/z6klwUxRwQI<br /><br /> // By Amit Agarwal - www.labnol.org<br /><br />}Nadia Chaudhrynoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-75666595829403695692013-06-03T11:53:25.248-04:002013-06-03T11:53:25.248-04:00Can I set my subject line to include one of the re...Can I set my subject line to include one of the responses in the form submission? For example, my form asks for a name, and I'd like to see the subject of the email as "Name's Form Submission" so I can quickly locate specific responses. Thanks!CHREGRnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-5613193590198572152013-05-24T14:28:10.753-04:002013-05-24T14:28:10.753-04:00I received the same error when submitting through ...I received the same error when submitting through the form. Could you help with the solution? I certainly appreciate your help.Aaronnoreply@blogger.comtag:blogger.com,1999:blog-8904812486779116235.post-15384103277528113272013-05-15T13:25:05.027-04:002013-05-15T13:25:05.027-04:00email me your code at david@confluentforms.comemail me your code at david@confluentforms.comDavid Kutcherhttp://www.confluentforms.com/noreply@blogger.com