Hey Jeff - I am doing a Fill In the Rhyme Workshop for a DEI Class I am launching. This was perfect for saving my students a step by taking their form and completing the document I will give them to rehearse from. You just helped me write my first little script - I am learning solidity as a hobby, so this was neat to incorporate into my education project. Worked like a charm. I got one error -misplaced comma that I quickly noticed and worked perfectly after that. Great job man - great pace, great detail, super job brother!
Jeff, 2 years after you posted, I was able to follow along and increase my paperwork productivity. Amazing. Now I have to research how to use a drop-down menu to print more extensive verbiage.
Hi, why this not work for me. It was an error: TypeError: Cannot read properties of undefined (reading 'values'). I copied the code but not working. Can you help me?
To be honest: this was way too complicated for me and I'm still stuck with the problem I am trying to solve 😂 But I am liking and comment for the algo, because I really like your energy in the tutorial. Thanks!
Thank you so much! I can't believe Google hasn't made a proper function between form and doc yet. I came here to learn this because I was trying to make one-link access to a form on my Role Playing Discord, for people to submit their Original Characters for roleplay, and then THAT response into a reference doc that I could share with all the players on discord about each player. Woo!
Thank you for this! I am a middle school teacher and in the course of less then an hour, I was able to make a form, and edit a template for lesson plans. It should save me dozens of hours in the future!
Jeff, I'm just getting back into coding and could not stand the online courses. I did your simple example, and it is indirectly related to one of my projects, and I am hooked. The code is simple but it gives me a start. Good job and thanks.
hi, thank you very much for this tutorial. I'm absolutely new to coding but this is exactly the usecase i need for work. However, when i copy your code and insert my file and folder ID's i always get this error notfication: function autoFillForm(e) { var name = e.values[0]; var nachname = e.values[1]; var standort = e.values[2]; TypeError: Cannot read property 'values' of undefined autoFillForm @ Code.gs:2 I haven't quiet understood the meaning of (e) in the function name Can you help?
Hi, You are super. How can it be done without creating a form? Print the data from the Google Sheet list to the word document. How will the script code be written?
Hi, thanks for watching. I've had so many people ask for an automation that runs from a sheet instead of a form, so I made a video and blog post that describes exactly that: ua-cam.com/video/iLALWX0_OYs/v-deo.html Thanks for watching!
15 minutes video = 3 lessons anticipated in the class room with rookies. I have 80 this year, so I should branch out for the German speaking students on the part vocational track towards a trainee position. I should be able to use the "title" to demonstrate the possibility of formatting the text for the more casual tone in Switzerland of maskuline and feminine in the text, to deviate from the unisex polite standard German "Sie" . A completed traineeship is for several topics qualifying for the University acceptance, including ETH Zürich.
Nice video. I took it as a base of a project using a sheet template instead. As several users will be sending responses at the same time, I preferred to use batch processes with triggers.
I've used this tutorial before to auto fill a google doc from a form, but I'm wanting to put my doc template in a google sheet. The main purpose is for that sheet to look similar to a doc if I were to print but to also have the ability use the "sum" function available in a sheet to add up info that will be added after the sheet is auto created from the script.
Hi Jeff! Your tutorial is amazing! Easy to understand and to follow. I'm just wondering if you also have a video on how to add the actual photos uploaded in Google Forms to the Google Doc? I have created a daily site report form that requires images from our project site. I want to see those images in the report in the Google Docs so I can just print it out and submit to our client
Hi!! Just saw your video, and I’m looking to create a contract for my business , so the workflow I envision is Client fills out form > it then populates the contract with some of the info they already filled out in the form, but my question is what do I do about the info that I need to add manually? I guess just add it manually?😅
Hello Jeff!! Thanks for this extremely helpful video. I hope I can get your help on these two questions: 1) How would I go about also creating an auto-saved PDF version of that google doc (a pdf that will download when i click the link in the column) perhaps in the column adjacent to this one: is this possible (do you have a link on your website for this as a tutorial?) 2) How do I get the script to STOP or NOT run if the actual spreadsheet row is empty? Sometimes I have a few extra empty rows in my GoogleSheet, and this script will keep running and essentially create empty documents. I assume this is something I can add as an "if" statement in the rows.forEach(function(row,index){}, and ive been trying to experiment but not able to figure it out. In otherwords, something for example, "if the first column of my spreadsheet is empty, DONT create a document, (e.g., return))". I tried adding in "if (row[1 === 0]) return;", which i understand to mean, if Column B in my spreadsheet is empty, skip this row, but that doesnt seem to work). ****EDITING MY QUESTION as i think i found my answer to my second question. I added if (row[1] == "") return; and that seemed to work :) Thanks in advance for your help for question 1 , and happy new year!!
How do you get it to update the same document over and over and add new rows of data to the same google doc? For instance, if I created a journal and I wanted my Google Forms entries to populate into my doc continuously?
Hi, it is a great video. Can I add an extra column in the spreadsheet which will replace the additional placeholder of the template? The extra column is not available in the google form.
Thank you so MUCH! Everything worked great. I ran into a problem. I completed these tasks to complete data walks on staff but I am stuck because I do not know how to auto share the doc I recreated from the responses. I am the responder because I am the one completing the form. How can I auto email each person their results.
I am curious about implementing a checkbox grid style of answer. For example, if I wanted to choose a specific location, then certain team members to assign to a project from that location, then it creates columns for each location. Is it possible to do an "if not blank" style of function to auto-populate the appropriate team members into the template doc? I have put in a e.namedVariable but then columns must be the same name and it doesn't tell the name of the location that way.
Is there anyway to populate a table located in your header that already has some data filled in example: company logo and company name are filled in but I have 6 other rows that need filled
Is there a way to get lots of responses to populate into a Google doc instead of a spreadsheet? I need a lot of information from people to automatically go to certain places on a specific form, but not a spreadsheet.
I want this but instead it's from Google Sheets. Is that possible? I have data in sheets then I want to create reports in docs? I want 1 page (doc) per row (sheet).
Hi Thomas! Thnak you for creating this video. I have followed it and created my script but for some reason it is not population into the google doc I want it to. Any suggestions?
Do you have anything updated? I tried this and I'm getting an error: TypeError: Cannot read properties of undefined (reading 'values'). This worked for me in the past but is no longer working.
Very helpful, but every so often (maybe 10% of the time) the form submission will fail to trigger the document creation, and nothing gets logged. Is there a way to re-run the trigger for the most recent form submission? Currently, if I try to manually re-run the trigger, I get an error, "TypeError: Cannot read properties of undefined (reading 'values')". I assume this is because it's going to the next line on the spreadsheet, which is blank. EDIT: I ended up using your follow-up video, "Auto Fill Google Doc Template from Google Sheets Data Using Google Apps Script". That method works as a workaround for when the form submission trigger fails.
I am having an issue with replacing the text in the Header. The code I used was: var body = doc.getHeader(); body.replaceText("{{Name}}", name); body.replaceText("{{Whatever is on my Doc}}", with one of the fields from the form); I used to use this but it no longer works. How do I replace the text in the Header with the text entered in the form? Thank you
Hey! Non developer here trying to better automate client status reports. With each new form submission will I be able to have the info added to the same document every time or will it create a new document?
hi Jeff, magnificent!! after trying, i managed to make it work.. anyway if I make another column in the sheets for example D2, containing "=left(a2,3)".... and i declare "var nick = e.values[4];".... and "body.replacetext('{{nick}}', nick);"..... the {{nick}} in the docs stay untouched, while the {{firstname}}, etc can be changed.. do you know what's wrong?
Is it possible to conditionally format paragraphs based on responses? An example would be the selection field will populate one paragraph if a certain selection and another with a different selection.
Short answer is absolutely you can do that. You would want to write an if/else statement that checks the value you want to look at, then run different replace function based on that check: www.w3schools.com/js/js_if_else.asp
This has been a great help, I am wondering if it is possible to save the doc to a specific folder and that folder would be correlated to a name from a drop down inside of the form itself?
So this video work perfect and I have used it. But I am needing help because my google doc is more complex with check boxes to match the google form. How can I add that to my app script to check the boxes on the doc like the google form?
Hello, the google document is successfully being generated in the response/populated folder but somehow when i opened the populated file, the values that are not being updated/changes from the google sheet to the google document. Here is the script im using: function autoFillNoticeOfPastDueAssessmentLetter(e){ var timestamp = e.values[0]; var hoaName = e.values[1]; var dateOfLetter = e.values[2]; var homeOwnerName = e.values[3]; var unitNumberStreet = e.values[4]; var city = e.values[5]; var state = e.values[6]; var zipCode = e.values[7]; var outstandingBalanceAmount = e.values[8]; var unitAccountNumber = e.values[9]; var mcmOfficeBranchNumber = e.values[10]; var templateFile = DriveApp.getFileById("1i9_EVGoS_SKfhZv1T4grw5Y2kHg_hgDo"); var templateResponseFolder = DriveApp.getFolderById("1mfkEknW-kmkzjDj5qQ9K_PM7gAj7UY1I"); var copy = templateFile.makeCopy(dateOfLetter + ', ' + hoaName + ', ' + homeOwnerName + ', ' + unitNumberStreet , templateResponseFolder); var doc = DocumentApp.openById(copy.getId()); var body = doc.getBody(); body.replaceText( body.replaceText("{{HOAName}}",hoaName); body.replaceText("{{Date}}",dateOfLetter); body.replaceText("{{HomeownerName}}",homeOwnerName); body.replaceText("{{UnitNumberStreet}}",unitNumberStreet); body.replaceText("{{City}}",city); body.replaceText("{{State}}",state); body.replaceText("{{ZipCode}}",zipCode); body.replaceText("{{OutstandingBalanceAmount}}",outstandingBalanceAmount); body.replaceText("{{UnitOwnerAccountNumber}}",unitAccountNumber); body.replaceText("{{MCMBranchPhoneNumber}}",mcmOfficeBranchNumber); doc.saveAndClose(); } Let me know what im doing wrong in this case. Thank you so much!
This was so helpful for me and my colleagues as we streamline some form submissions at our school. As a chemistry teacher- I know zero coding terms so please bear with me! We were wondering if there is a way to add code around line 10 for the file name to add a 1,2,3 ect if the same person submits the form. Ex. John Doe 1, John Doe 2. We have students who should complete the form once, but sometimes redo if they need to. (I know we can look at time stamps- we are just trying to streamline it). We also wondered if there is a way for the new document created's link to be inserted in the spreadsheet's row for that document. This tutorial was amazingly helpful! Thank you so much for it as well as the vast amount of information on your site!
I got the following message when I clicked on "run" after following your instructions. TypeError: Cannot read property 'values' of undefined (line 2, file "Code") This is my line 2- var timestamp = e.values[0]; Do you have any suggestions? Also, I am playing around with the triggers etc. Is there a way to get a document to generate and appear in the folder for a form response that was already submitted? For example, I tried putting a trigger for On Edit, and On Change, and On Open. I then proceeded to close and re-open the response spreadsheet, and edit one of the phone numbers on a response that was submitted before I created this script, and nothing happened that I can see. I have 2 people who have already submitted, and when I do a test one it works, but I don't want to ask my people to resubmit the form, nor do I want to type all their info just to get it into a document, was hoping for a way to grab those old ones and make them transfer. Upon playing with the different triggers, I believe it sent the Summary of Failures email to me at those times with more info on the Error, the email says the following: TypeError: Cannot read property '0' of undefined So I am not sure what I am missing, but the rest works fine when a new form is filled out and submitted, just don't know why there is a small error in there somewhere? Thanks for a very helpful and informative video for someone who has never done anything like this before! I would love to learn more!
This is so helpful! What might I do if I have a question on my form that allows for checkbox/multiple answers? How would we deal these out to specific cells?
is there a way to put a date rage in one document. It would be awesome if all rows could be pulled into one document. For example let's say you have 10 employees and wanted to generate a report showing all 10 on 1 document not 10 separate docs.
Hey Jeff, First of all, this video was so amazing! Thank you so much for making this. I do have a couple of questions that hopefully you can address. 1. If I was to enable the form to upload a photo, How would I go about ensuring that the google doc pasted in the actual photo instead of just a link to where the file is located on my google drive? Is this possible to do? How would I go about doing it? 2. I was trying to make it to where the populated file would then email itself to whoever filled out the form with their answers. I have it configured to where the form emails the person a .PDF copy of the google but I would like it to send a word doc instead. Preferably a .DOCX. When I use the MimeType function, it only works when I use .PDF. If I put in any other file type extension i get an error. The form still populates a new doc in the folder but it won't send the email of that particular doc. Any suggestions on fixing these issues?
How can I make it work for many data information, I mean having a lot of names and dates .... in google sheets and want them all be in one google doc table. I want to auto create invoices with one client buying many articles and its complicated for i hope you can help me with that. Thank you for all your efforts ❤❤
Check this out, it does something similar to what you are asking for: jeffreyeverhart.com/2020/05/18/open-letter-maker-with-google-forms-docs-and-apps-script/
Does this method still work? Tried using "e" as a parameter and seems like the script doesn't know that I'm referring to the spreadsheet populated by the form.
Thanks so much for this. My last line is giving me so much issues and wont let me trigger. it keeps saying Syntax error: SyntaxError: Unexpected end of input line: 51 file: Code.gs.............. I have everything typed correctly, what should i do? It aslo says I dont have any target functions. I dont know what else to do... Could my template not be in the right place?
Hi Jeff! Thank you for the great video. When I go to add a trigger there is no "from spreadsheet" option for event source. Any idea why this might be and any recs on how I can fix this? Thanks!
@@jeffeverhart I had the problem and then realized that strangely when I went to create a trigger I had been switched to one of my different Google accounts. To fix this I just temporarily signed out of my other accounts and that fixed the problem.
You'd use the getAs method to get as a PDF then DriveApp to save the file: developers.google.com/apps-script/reference/document/document#getascontenttype
Hi, thank you for this tutorial. One question I hope you can answer: instead of generating new templates for every new form responses, how can I add new forms response data to existing docs depending on the options chosen in the docs (example: person A selects it's them filling out the form in the first option, so everything thereafter gets added to their specific doc template?!). I really hope you can help! Thank you
Hi Jeff, Great video! I'm not sure if this question has been answered but I have a template made in docs that I make a copy of each time I need to fill it out. Is it possible with this method to have it autofill a new copy from a pre-made template? Basically, I need a new doc created from every form submission from a template that's already been created.
@@wadekmali This seems to be the closest thing I can find. ua-cam.com/video/TSDXfdo3JVU/v-deo.html I haven't had a chance to try it as I am still awaiting admin approval but if you do, let me know!
If you look at the video at this timestamp, the script does make a copy of the original template. This creates a new doc per submission, and keeps the original: ua-cam.com/video/ziLtj5-_D7c/v-deo.html
I really loved this tutorial. Very well detailed, and the code part is also very well explained. I have a question. If I want to put all the answers in one Google like a list of names, nationalities, age, etc; how would it be?
Hi Jeff, very well done ... and it helped me a lot. But i have another issue ... ( e.g. an Invoice with header informations and then a table with the invoice items ) In my template the items are in a table ... and this is where the problem starts. How can i fill in a loop item for item in the docs template ( items in a table ) ... All over the net i found no solution ... 😢
Thanks for the tutorial. I have one question, does the table in the google doc append whenever someone submits a form or it will go to a new google doc?
Is there any way to generate responses into the Doc from a checkbox of items on the Form, inserting only the items checked? Does that make sense? Thank you for the great tutorial! I am working on creating this for my team.
Is it possible to autofill the sum of multiple entries? I have only been able to concatenate entries like strings and despite reading the documentation I cannot seem to get it to treat the cell values as ints.
You should be able to do a type conversion using parseInt, and then it would be just doing the math operations you want: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt Let me know if I'm missing something. Thanks for watching!
Hi Jeff, very helpful video - thank you! Wondering if there is a way to then send the completed Google Doc as either a Google Doc or a pdf for the person that filled out the Google Form. (one of the Google Form questions would be email address). Looking forward to your reply.
This is fanstastic, easy to use. One question, I got it working great except it duplicates on form submission and creates two identical docs in my destination folder. any thoughts on what I goofed up?
how can you declare (e) ??? it is not working when i try this script
This was exactly what I was looking for to populate a document with client info, thank you!
Awesome! Glad it worked for you. Thanks for watching!
@@jeffeverhart dude you are well spoken, at the right pacing and nailed this guide for a not-casual-actually-stupid-person :) way to go!
Yes thank you
@@jeffeverhart please make more complicated stuff for appscript
Thanks, any thoughts on what topics you'd like to see covered?
Hey Jeff - I am doing a Fill In the Rhyme Workshop for a DEI Class I am launching. This was perfect for saving my students a step by taking their form and completing the document I will give them to rehearse from. You just helped me write my first little script - I am learning solidity as a hobby, so this was neat to incorporate into my education project. Worked like a charm. I got one error -misplaced comma that I quickly noticed and worked perfectly after that. Great job man - great pace, great detail, super job brother!
I love how you went over each code line by line
Thanks for the kind words
Jeff, 2 years after you posted, I was able to follow along and increase my paperwork productivity. Amazing. Now I have to research how to use a drop-down menu to print more extensive verbiage.
Awesome, glad this helped you out
Thank you, Thank you, Thank you. This is perfect for quickly creating, organizing, and sharing lesson plans.
Glad it was helpful! Thanks for watching
Hi, why this not work for me. It was an error: TypeError: Cannot read properties of undefined (reading 'values'). I copied the code but not working. Can you help me?
To be honest: this was way too complicated for me and I'm still stuck with the problem I am trying to solve 😂 But I am liking and comment for the algo, because I really like your energy in the tutorial. Thanks!
Thank you so much! I can't believe Google hasn't made a proper function between form and doc yet. I came here to learn this because I was trying to make one-link access to a form on my Role Playing Discord, for people to submit their Original Characters for roleplay, and then THAT response into a reference doc that I could share with all the players on discord about each player. Woo!
Awesome! I'm glad this worked well for you. Thanks for watching!
I got an error saying that the e and the other values from e is undefined
nice video, question
TypeError: Cannot read properties of undefined (reading 'values')
how to fix that?
even I got the same when I tried today , got any fix for it ?
The best, easiest, simplest explanation i'v ever seen!
Thank you so much1
Thank you for this!
I am a middle school teacher and in the course of less then an hour, I was able to make a form, and edit a template for lesson plans. It should save me dozens of hours in the future!
Awesome, Jason! Always glad when I can help a teacher save some time in the classroom.
@@jeffeverhart I see so many other possibilities..
I could make Google Form and have it fill out an Essay even. The possibilities are endless!
Finally. I have been looking for this solution. Thanks for the explanation Jeff.
you are welcome. Thanks for watching!
Jeff, I'm just getting back into coding and could not stand the online courses. I did your simple example, and it is indirectly related to one of my projects, and I am hooked. The code is simple but it gives me a start. Good job and thanks.
Tried used it but get error cannot read properties of undefined (reading 'values'...
u saved so much time for me and my internship. thank you!
hi,
thank you very much for this tutorial. I'm absolutely new to coding but this is exactly the usecase i need for work. However, when i copy your code and insert my file and folder ID's i always get this error notfication:
function autoFillForm(e) {
var name = e.values[0];
var nachname = e.values[1];
var standort = e.values[2];
TypeError: Cannot read property 'values' of undefined
autoFillForm @ Code.gs:2
I haven't quiet understood the meaning of (e) in the function name
Can you help?
Same issue here
@@XxXVidmanXxX Exactly the same error here.
Thank You for this walk through. Clear, organized and Concise! Really helped me see what is possible with Apps scripting. 👌
Glad it was helpful!
Hi,
You are super.
How can it be done without creating a form?
Print the data from the Google Sheet list to the word document.
How will the script code be written?
Hi, thanks for watching. I've had so many people ask for an automation that runs from a sheet instead of a form, so I made a video and blog post that describes exactly that: ua-cam.com/video/iLALWX0_OYs/v-deo.html
Thanks for watching!
Thank you for the knowledge. How do I make this successful TypeError: Cannot read properties of undefined (reading 'values')?
15 minutes video = 3 lessons anticipated in the class room with rookies. I have 80 this year, so I should branch out for the German speaking students on the part vocational track towards a trainee position. I should be able to use the "title" to demonstrate the possibility of formatting the text for the more casual tone in Switzerland of maskuline and feminine in the text, to deviate from the unisex polite standard German "Sie" .
A completed traineeship is for several topics qualifying for the University acceptance, including ETH Zürich.
Nice video. I took it as a base of a project using a sheet template instead. As several users will be sending responses at the same time, I preferred to use batch processes with triggers.
I've used this tutorial before to auto fill a google doc from a form, but I'm wanting to put my doc template in a google sheet. The main purpose is for that sheet to look similar to a doc if I were to print but to also have the ability use the "sum" function available in a sheet to add up info that will be added after the sheet is auto created from the script.
the 'e' value is undefined. how do i make this work?
Facing the same issue what did i do wrong
Super useful, concise, and easy to follow. Thank you!
Thanks for watching! I'm glad it was helpful
I'm getting errors with the "e.values" part. Any thoughts on what the problem might be?
I am! not sure whats going on :(
A few reasons outlined here: jeffreyeverhart.com/2016/08/06/fix-typeerror-cannot-read-property-values-undefined/
thanks for the tutorial.... what is the code for upload a image?
Jeff, thanks so much for this tutorial. Well presented, clear and it worked for my Form processing. Much appreciated.
Hi Jeff! Your tutorial is amazing! Easy to understand and to follow. I'm just wondering if you also have a video on how to add the actual photos uploaded in Google Forms to the Google Doc? I have created a daily site report form that requires images from our project site. I want to see those images in the report in the Google Docs so I can just print it out and submit to our client
This will save me so much time Jeff! Kudos
Hi!! Just saw your video, and I’m looking to create a contract for my business , so the workflow I envision is Client fills out form > it then populates the contract with some of the info they already filled out in the form, but my question is what do I do about the info that I need to add manually? I guess just add it manually?😅
Hello Jeff!! Thanks for this extremely helpful video. I hope I can get your help on these two questions:
1) How would I go about also creating an auto-saved PDF version of that google doc (a pdf that will download when i click the link in the column) perhaps in the column adjacent to this one: is this possible (do you have a link on your website for this as a tutorial?)
2) How do I get the script to STOP or NOT run if the actual spreadsheet row is empty? Sometimes I have a few extra empty rows in my GoogleSheet, and this script will keep running and essentially create empty documents. I assume this is something I can add as an "if" statement in the rows.forEach(function(row,index){}, and ive been trying to experiment but not able to figure it out. In otherwords, something for example, "if the first column of my spreadsheet is empty, DONT create a document, (e.g., return))". I tried adding in "if (row[1 === 0]) return;", which i understand to mean, if Column B in my spreadsheet is empty, skip this row, but that doesnt seem to work).
****EDITING MY QUESTION as i think i found my answer to my second question. I added
if (row[1] == "") return;
and that seemed to work :)
Thanks in advance for your help for question 1 , and happy new year!!
Just wanna know if this applicable if i have an existingntemplate fill it in docs?
How to get linear scale data from form to google docs.please help me out
How do you get it to update the same document over and over and add new rows of data to the same google doc? For instance, if I created a journal and I wanted my Google Forms entries to populate into my doc continuously?
I can't find script editor!
help someone
Thanks for the good information. We look forward to the continuation.
I dont have the option to select event source "from spreadsheet", what do i do
Hi, it is a great video. Can I add an extra column in the spreadsheet which will replace the additional placeholder of the template? The extra column is not available in the google form.
Thank you so MUCH! Everything worked great. I ran into a problem. I completed these tasks to complete data walks on staff but I am stuck because I do not know how to auto share the doc I recreated from the responses. I am the responder because I am the one completing the form. How can I auto email each person their results.
Hey I need help i want to add the new file in same document but new page .
Thanks for the video! What about in the case of uploaded images in Google Forms?
Everything appears to work except for the replaceTest part. Thoughts?
Thank you... your vid helps me a lot...
can we have a document section too added to the last column which can automatically be filled whenever auto-generated document is created?
I am curious about implementing a checkbox grid style of answer. For example, if I wanted to choose a specific location, then certain team members to assign to a project from that location, then it creates columns for each location. Is it possible to do an "if not blank" style of function to auto-populate the appropriate team members into the template doc? I have put in a e.namedVariable but then columns must be the same name and it doesn't tell the name of the location that way.
Is there anyway to populate a table located in your header that already has some data filled in example: company logo and company name are filled in but I have 6 other rows that need filled
Can we also auto fill google doc with images that is submitted from the Google Form?
How can you auto link that document to a cell that corresponds with the submission in the google spreadsheet?
Is there a way to get lots of responses to populate into a Google doc instead of a spreadsheet? I need a lot of information from people to automatically go to certain places on a specific form, but not a spreadsheet.
I want this but instead it's from Google Sheets. Is that possible? I have data in sheets then I want to create reports in docs? I want 1 page (doc) per row (sheet).
Hi Thomas! Thnak you for creating this video. I have followed it and created my script but for some reason it is not population into the google doc I want it to. Any suggestions?
Do you have anything updated? I tried this and I'm getting an error: TypeError: Cannot read properties of undefined (reading 'values'). This worked for me in the past but is no longer working.
Very helpful, but every so often (maybe 10% of the time) the form submission will fail to trigger the document creation, and nothing gets logged. Is there a way to re-run the trigger for the most recent form submission? Currently, if I try to manually re-run the trigger, I get an error, "TypeError: Cannot read properties of undefined (reading 'values')". I assume this is because it's going to the next line on the spreadsheet, which is blank.
EDIT: I ended up using your follow-up video, "Auto Fill Google Doc Template from Google Sheets Data Using Google Apps Script". That method works as a workaround for when the form submission trigger fails.
I am having an issue with replacing the text in the Header. The code I used was:
var body = doc.getHeader();
body.replaceText("{{Name}}", name);
body.replaceText("{{Whatever is on my Doc}}", with one of the fields from the form);
I used to use this but it no longer works. How do I replace the text in the Header with the text entered in the form? Thank you
Hey! Non developer here trying to better automate client status reports. With each new form submission will I be able to have the info added to the same document every time or will it create a new document?
hi Jeff, magnificent!!
after trying, i managed to make it work.. anyway if I make another column in the sheets for example D2, containing "=left(a2,3)".... and i declare "var nick = e.values[4];".... and "body.replacetext('{{nick}}', nick);"..... the {{nick}} in the docs stay untouched, while the {{firstname}}, etc can be changed.. do you know what's wrong?
Is it possible to conditionally format paragraphs based on responses? An example would be the selection field will populate one paragraph if a certain selection and another with a different selection.
Short answer is absolutely you can do that. You would want to write an if/else statement that checks the value you want to look at, then run different replace function based on that check: www.w3schools.com/js/js_if_else.asp
This has been a great help, I am wondering if it is possible to save the doc to a specific folder and that folder would be correlated to a name from a drop down inside of the form itself?
is it work for spreadsheet to?
So this video work perfect and I have used it. But I am needing help because my google doc is more complex with check boxes to match the google form. How can I add that to my app script to check the boxes on the doc like the google form?
Hello, the google document is successfully being generated in the response/populated folder but somehow when i opened the populated file, the values that are not being updated/changes from the google sheet to the google document.
Here is the script im using:
function autoFillNoticeOfPastDueAssessmentLetter(e){
var timestamp = e.values[0];
var hoaName = e.values[1];
var dateOfLetter = e.values[2];
var homeOwnerName = e.values[3];
var unitNumberStreet = e.values[4];
var city = e.values[5];
var state = e.values[6];
var zipCode = e.values[7];
var outstandingBalanceAmount = e.values[8];
var unitAccountNumber = e.values[9];
var mcmOfficeBranchNumber = e.values[10];
var templateFile = DriveApp.getFileById("1i9_EVGoS_SKfhZv1T4grw5Y2kHg_hgDo");
var templateResponseFolder = DriveApp.getFolderById("1mfkEknW-kmkzjDj5qQ9K_PM7gAj7UY1I");
var copy = templateFile.makeCopy(dateOfLetter + ', ' + hoaName + ', ' + homeOwnerName + ', ' + unitNumberStreet , templateResponseFolder);
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();
body.replaceText(
body.replaceText("{{HOAName}}",hoaName);
body.replaceText("{{Date}}",dateOfLetter);
body.replaceText("{{HomeownerName}}",homeOwnerName);
body.replaceText("{{UnitNumberStreet}}",unitNumberStreet);
body.replaceText("{{City}}",city);
body.replaceText("{{State}}",state);
body.replaceText("{{ZipCode}}",zipCode);
body.replaceText("{{OutstandingBalanceAmount}}",outstandingBalanceAmount);
body.replaceText("{{UnitOwnerAccountNumber}}",unitAccountNumber);
body.replaceText("{{MCMBranchPhoneNumber}}",mcmOfficeBranchNumber);
doc.saveAndClose();
}
Let me know what im doing wrong in this case.
Thank you so much!
Jeff, can we auto fill image to the docs after image upload respond in google form?
This was so helpful for me and my colleagues as we streamline some form submissions at our school. As a chemistry teacher- I know zero coding terms so please bear with me! We were wondering if there is a way to add code around line 10 for the file name to add a 1,2,3 ect if the same person submits the form. Ex. John Doe 1, John Doe 2. We have students who should complete the form once, but sometimes redo if they need to. (I know we can look at time stamps- we are just trying to streamline it). We also wondered if there is a way for the new document created's link to be inserted in the spreadsheet's row for that document. This tutorial was amazingly helpful! Thank you so much for it as well as the vast amount of information on your site!
Man, I can't believe this worked, thank you so much.
Awesome, thanks for watching!
Help! I've copied the script exactly but keep getting an error: "TypeError: cannot read property 'values' of undefined"
Check out this link to a blog post that describes that error: jeffreyeverhart.com/2016/08/06/fix-typeerror-cannot-read-property-values-undefined/
How do you send it as pdf attachment to the provided email address
Just got an error -> TypeError: Cannot read property '0' of undefined
The reason is that you have attached the code on the form not the form itself
@@lukeandsallylowandmarion2584 Hi, Could you expand on this comment?
Since the creation of this video, I can't find Script Editor under TOOLS in Google Sheets. What's the updated procedure?
IS THERE ANY WAY, WE GET GOOGLE FORM FIELDS AUTOFILLED FROM GOOGLE SHEET VALUES (NOT WITH PREFILLED LINKS)
Are you able to do If statements in the word document like you can in MailMerge?
I got the following message when I clicked on "run" after following your instructions. TypeError: Cannot read property 'values' of undefined (line 2, file "Code")
This is my line 2-
var timestamp = e.values[0];
Do you have any suggestions?
Also, I am playing around with the triggers etc. Is there a way to get a document to generate and appear in the folder for a form response that was already submitted? For example, I tried putting a trigger for On Edit, and On Change, and On Open. I then proceeded to close and re-open the response spreadsheet, and edit one of the phone numbers on a response that was submitted before I created this script, and nothing happened that I can see. I have 2 people who have already submitted, and when I do a test one it works, but I don't want to ask my people to resubmit the form, nor do I want to type all their info just to get it into a document, was hoping for a way to grab those old ones and make them transfer.
Upon playing with the different triggers, I believe it sent the Summary of Failures email to me at those times with more info on the Error, the email says the following:
TypeError: Cannot read property '0' of undefined
So I am not sure what I am missing, but the rest works fine when a new form is filled out and submitted, just don't know why there is a small error in there somewhere?
Thanks for a very helpful and informative video for someone who has never done anything like this before! I would love to learn more!
This is so helpful! What might I do if I have a question on my form that allows for checkbox/multiple answers? How would we deal these out to specific cells?
is there a way to put a date rage in one document. It would be awesome if all rows could be pulled into one document. For example let's say you have 10 employees and wanted to generate a report showing all 10 on 1 document not 10 separate docs.
Hey Jeff,
First of all, this video was so amazing! Thank you so much for making this. I do have a couple of questions that hopefully you can address.
1. If I was to enable the form to upload a photo, How would I go about ensuring that the google doc pasted in the actual photo instead of just a link to where the file is located on my google drive? Is this possible to do? How would I go about doing it?
2. I was trying to make it to where the populated file would then email itself to whoever filled out the form with their answers. I have it configured to where the form emails the person a .PDF copy of the google but I would like it to send a word doc instead. Preferably a .DOCX. When I use the MimeType function, it only works when I use .PDF. If I put in any other file type extension i get an error. The form still populates a new doc in the folder but it won't send the email of that particular doc.
Any suggestions on fixing these issues?
I have the same image question. The URL as text passes fine, but how about getting that image to embed?
How can I make it work for many data information, I mean having a lot of names and dates .... in google sheets and want them all be in one google doc table.
I want to auto create invoices with one client buying many articles and its complicated for i hope you can help me with that. Thank you for all your efforts ❤❤
Check this out, it does something similar to what you are asking for: jeffreyeverhart.com/2020/05/18/open-letter-maker-with-google-forms-docs-and-apps-script/
@@jeffeverhart Thank you jeff you are the best !
Does this method still work? Tried using "e" as a parameter and seems like the script doesn't know that I'm referring to the spreadsheet populated by the form.
Thanks so much for this. My last line is giving me so much issues and wont let me trigger. it keeps saying Syntax error: SyntaxError: Unexpected end of input line: 51 file: Code.gs.............. I have everything typed correctly, what should i do? It aslo says I dont have any target functions. I dont know what else to do... Could my template not be in the right place?
Thank you but how I wish we can also email that document to the user.
Hi Jeff! Thank you for the great video. When I go to add a trigger there is no "from spreadsheet" option for event source. Any idea why this might be and any recs on how I can fix this? Thanks!
Is the script attached to the spreadsheet and not the form? It needs to be in the spreadsheet.
@@jeffeverhart I had the problem and then realized that strangely when I went to create a trigger I had been switched to one of my different Google accounts. To fix this I just temporarily signed out of my other accounts and that fixed the problem.
@@jeffeverhart That solved it for me!
What would I add to the script to make it save as a pdf?
You'd use the getAs method to get as a PDF then DriveApp to save the file: developers.google.com/apps-script/reference/document/document#getascontenttype
Hi, thank you for this tutorial. One question I hope you can answer: instead of generating new templates for every new form responses, how can I add new forms response data to existing docs depending on the options chosen in the docs (example: person A selects it's them filling out the form in the first option, so everything thereafter gets added to their specific doc template?!). I really hope you can help! Thank you
Is it possible to get the uploaded image from my form displayed as an image in docs.
Is it possible to take this one step further, and convert the DOC to PDF. And then automate an email with the pdf attached?
Can you make video about how a section can increase in numbers? Example Test 0 increases to 1 each time the form is used.
Are you using Producer edition?? What do y'all recomnd if I want to make s but not record my voice or tutorial?
Hi Jeff, Great video! I'm not sure if this question has been answered but I have a template made in docs that I make a copy of each time I need to fill it out. Is it possible with this method to have it autofill a new copy from a pre-made template? Basically, I need a new doc created from every form submission from a template that's already been created.
I'm working towards the same thing, please let me know if you figure it out! Good luck!
@@wadekmali This seems to be the closest thing I can find. ua-cam.com/video/TSDXfdo3JVU/v-deo.html I haven't had a chance to try it as I am still awaiting admin approval but if you do, let me know!
If you look at the video at this timestamp, the script does make a copy of the original template. This creates a new doc per submission, and keeps the original: ua-cam.com/video/ziLtj5-_D7c/v-deo.html
how if value in footer with different first page doesn't change {{footer}}?
I really loved this tutorial. Very well detailed, and the code part is also very well explained. I have a question. If I want to put all the answers in one Google like a list of names, nationalities, age, etc; how would it be?
Hi Jeff, very well done ... and it helped me a lot. But i have another issue ... ( e.g. an Invoice with header informations and then a table with the invoice items )
In my template the items are in a table ... and this is where the problem starts. How can i fill in a loop item for item in the docs template ( items in a table ) ... All over the net i found no solution ... 😢
Thanks for the tutorial. I have one question, does the table in the google doc append whenever someone submits a form or it will go to a new google doc?
why can't there just be a button in Google Forms that says export to Google Docs, (or something similar...
Thanks, Jeff, is there any way possible to convert the google doc that we got into a PDF?
I would have wanted that too
You can see an example of that here: jeffreyeverhart.com/2015/01/30/tech-tip-google-forms-confirmation-email-with-attachments/
Is there any way to generate responses into the Doc from a checkbox of items on the Form, inserting only the items checked? Does that make sense? Thank you for the great tutorial! I am working on creating this for my team.
Is there a way to do it backwards? Use a scrip to auto fill the google form
Is it possible to autofill the sum of multiple entries? I have only been able to concatenate entries like strings and despite reading the documentation I cannot seem to get it to treat the cell values as ints.
You should be able to do a type conversion using parseInt, and then it would be just doing the math operations you want: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Let me know if I'm missing something. Thanks for watching!
Hi Jeff, very helpful video - thank you! Wondering if there is a way to then send the completed Google Doc as either a Google Doc or a pdf for the person that filled out the Google Form. (one of the Google Form questions would be email address). Looking forward to your reply.
This is fanstastic, easy to use. One question, I got it working great except it duplicates on form submission and creates two identical docs in my destination folder. any thoughts on what I goofed up?
just asking can you save it as pdf is it possible?