Google Forms to PDF & Email while storing data in Google Sheets

Learn Google Sheets & Excel Spreadsheets · 190K views · 2020 · 27:02

Open on YouTube

Python, Ruby & scripting languagesSoftware practice, open source & careerstutorial

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they followed when building a form-to-PDF-to-email script, and then ask about errors in the resulting code.

Recommended by 0 people across 0 different months, 2021 to 2025.

What it is

A 27-minute Google Apps Script tutorial that takes a Google Forms submission, stores it in Google Sheets, fills a Google Doc template, and saves the result as a PDF in Drive. It then adds the PDF link to the spreadsheet and emails the PDF as an attachment to the respondent. It is presented on the Learn Google Sheets & Excel Spreadsheets channel.

What people said

Cites Brian · 2021-05 · Stack Overflow · on “Generate a PDF on Form Submit”

Hi I am new to the forum and programming Google Scripts. I am a Technology teacher and I am trying to develop a course tracking software for my students. I have been watching videos on [this video] trying to get a Form to automatically generate a PDF and later email that PDF to my students and their parents. I am at the point where my lack of knowledge is catching up to me. I was able to get the Create PDF function to work on it's own but I cannot get my code to generate a PDF after being triggered by a Form Submit. When I run the afterFormSubmit function I get the following error: TypeError: Cannot read property 'namedValues' of undefined. Here is my code and error report - I would appreciate an

Cites Thanakorn Sairat · 2021-05 · Stack Overflow · on “Google Script Link PDF : Exception: Argument cannot be null: contentType (line 82, file "Code")”

I was trying to write a script that, when you submit a google form, it puts a pdf link to my Google Sheets. However, there seems to be some kind of error. I don't have any experience at all whatsoever with Google Sheets, so I just copied it from some YouTube video and adjusted it a bit function onOpen(e) { SpreadsheetApp.getUi().createMenu('Create PDF').addItem('Create PDF', 'createPDF').addToUi(); } //create a PDF File function afterFormSubmit(e) { const info = e.namedValues; const pdfFile = createPDF(info); const entryRow = e.range.getRow(); const ws = SpreadsheetApp.getActiveSpreadsheet.getSheetByName('Electric Forklift Incentive'); ws.getRange(entryRow, 40).setValue(pdfFile.getUrl()); }

Cites Thanakorn Sairat · 2021-05 · Stack Overflow · on “Google Script link PDF error: Cannot read property 'namedValues' of undefined”

I was trying to write a script that, when you submit a google form, it puts a pdf link to my Google Sheets. However, there seems to be some kind of error. I don't have any experience at all with Google Sheets, so I just copied it from some YouTube video and adjusted it a bit. [this video] The problem says: TypeError: Cannot read property 'namedValues' of undefined (line 27, file "Code") Can someone help me to understand the reason of this error? This is the sheet link: [LINK] And here is the worksheet: [LINK] function afterFormsubmit(e) { const info = e.namedValues ; const pdfFile = createPDF(info); const entryRow = e.range.getRow(); const ws = SpreadsheetApp.getActiveSpreadsheet.getSheetByName('

Cites mohitji · 2021-10 · Stack Overflow · on “How to Generate PDF of an image response submitted in Google form and send Auto email to the respondent with attachment as PDF”

I am developing a google form which have some text field and image field. Now after submission I am able to generate pdf of text responses. Also the pdf of responses is sent to the respondent email. I have referred to this Video Tutorial [this video] . Script used for text : function afterFormSubmit(e) { const info = e.namedValues; const pdfFile=createPDF(info); const entryRow=e.range.getRow(); SpreadsheetApp.getActiveSpreadsheet().getSheetByName("People").getRange(entryRow,6).setValue(pdfFile.getUrl()); sendEmail(e.namedValues["Email"], pdfFile); } function sendEmail(email, pdfFile){ GmailApp.sendEmail(email, "Succesfuly filled the form ", {attachments:[pdfFile],name:"Test Case" }); } function c

Cites Robin Lefebvre · 2022-03 · Stack Overflow · on “gmailapp.sendemail outgoing mail gets blocked when send to a gmail account”

First off I am not an IT wizard, I am ok at using other people code. So ... please keep it simple, perhaps use crayons when explaining it to me. I've made an online questionnaire that auto-sends the report as a pdf attachment to the participant, using google forms + google sheets + apps script (source of inspiration: [this video] ). It works great, except if the user has a gmail account. Rather than sending the email to participant I get an auto reply that the message may contain a virus. My code: function afterFormSubmit(e) { const info = e.namedValues; const entryRow = e.range.getRow(); const wsData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data"); const wsResponses = SpreadsheetA

Cites imguessing · 2022-04 · Stack Overflow · on “Appscript Gmail PDF not attached but showing [object][Object] instead”

I followed a tutorial here: [this video] . The script below creates a PDF upon a google form submit and sends the PDF to a specified email address. Everything works except that instead of the PDF being attached, the email is sent without a PDF, with the words [object Object] in the email body and I have no idea why! Also a second problem: 2 PDF files are being created for every 1 form submission. Can anyone solve this too? Here is my code: function afterFormSubmit(e) { const info = e.namedValues; const pdfFile = createPDF(info); createPDF(info); sendEmail(e.namedValues['Your Email Address'][0],pdfFile); } function sendEmail(email, pdfFile){ console.log(pdfFile); GmailApp.sendEmail(email,"here is

Cites Justin Holt · 2023-12 · Stack Overflow · on “Google Appscript code to auto create, attach, and send a pdf created from a Google Form through email not working?”

I am trying to create an automated report for my Team. I have a very basic understanding of coding but not enough to really troubleshoot or add my own code when something goes wrong or doesn't work. I appreciate any help in advance. When my Team fills out the form there is a drop down question for the email where they will choose which location to email the PDF to, so that it can be printed out and signed. It is this email in column C that I need the script to identify and use to send the email and attached PDF. I found this video [this video] and followed it step by step, except for one section where he collects emails and sets up pdf links within the spreadsheet (under the "Adding a Link to the

Cites Sam Murdock · 2025-01 · Stack Overflow · on “I keep getting Exception: Invalid argument: replacement on a google Apps Script”

Trying to convert google form into a pdf and then email it. Currently it stores the data into an array, and then later grabs that info, puts it into a doc instead of a form. When it gets to grabbing the info is where it keeps throwing an error. function createPDF(){ // all info collected on the form, pre-filled to test const info = { 'First Name' : ['Mike'], 'Last Name' : ['Wazowski'], 'Birthday' : [0], 'Email' : ['m@w.com'], 'Phone Number' : ['1'], 'Province' : ['Ontario'], 'Contact Method' : ['email'], 'Language': ['english'], 'Type Of Service': ['in person'], 'Child Name': [], 'Child Birthday': [], 'Services Required': ['counselling'], 'Staff Requested': ['Nancy'], 'Priority':['Health'],