Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
TypeError: Cannot read property 'namedValues' of undefined and 2 other errors

I am very new with Apps Script and I am trying to generate a pdf file upon form submission and send it in an email. I have been trying to fix this for a over a week. I have watched every on tutorial and read numerous articles multiple times to see if I can find where my mistakes are. I am getting 2 errors

  1. TypeError: Cannot read property 'namedValues' of undefined
  2. TypeError: Cannot read property 'Timestamp' of undefined at createPDF

Can someone help me with this? The code that I have so far is below:

function afterFormSubmit(e){

  const info = e.namedValues;
  createPDF(info); 
}

function createPDF(info) {    

const pdfFolder = DriveApp.getFolderById("1tSVmV7-HzZHoYYPBfG1cdImNGuckB2S3")
const tempFolder = DriveApp.getFolderById("1oqyfbwjr21OaPi3rCICgZhIQrU6C4wwA")
const templateDoc = DriveApp.getFileById("18F0iOfZ_Iu71UxjDzRDVjFMRvBA20ATnRX8-E8cy5q0");

const newTempFile = templateDoc.makeCopy(tempFolder)
const OpenDoc = DocumentApp.openById(newTempFile.getId());
const body = OpenDoc.getBody();
   

    body.replaceText("{dt}", info['Timestamp'][0]);
    body.replaceText("{cn}", info['Company Name:'][0]);
    body.replaceText("{jc}", info['Job Code:'][0]);
    body.replaceText("{st}", info['Scope of Work Type:'][0]);
    body.replaceText("{ot}", info['If "Other", please specify:'][0]);
    body.replaceText("{dc}", info['Description of Change:'][0]);
    body.replaceText("{mc}", info['Materials and Cost:'][0]);
    body.replaceText("{lc}", info['Labor Cost:'][0]);
    body.replaceText("{tx}", info['Tax Cost:'][0]);
    body.replaceText("{tl}", info['Total:'][0]);
    OpenDoc.saveAndClose();

  const blobPDF = newTempFile.getAs(MimeType.PDF);
  const pdfFile = pdfFolder.createFile(blobPDF).setName(info['Job Code:'][0] + " " + info['Company Name:'][0]); 
  tempFolder.removeFile(newTempFile);
}
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda