This script is intended to create a customize PDF file based on the google form responses. This worked a few days back and suddenly it stopped executing.
The object in question ("info") seems to be present but it still returning an error of being undefined
The object, "info", is based on the google sheet header where the google form responses are collected/saved as shown below:
This is the error:
And when debugged, it would show that object "info" is undefined:
For reference, this is the script:
function createPDF(info) {
const pdfFolder = DriveApp.getFolderById("1GiY42M3rTq36M9pnUq7Y6RE1qQ8TFN8X");
const tempFolder = DriveApp.getFolderById("1bkzpVTURICEvcJWemFGaOYTZSdeF_XNj");
const templateDoc = DriveApp.getFileById("1UfFzcIdG1DCAYpk-NWSiA7bEoz1ZSJXeuV_9-Okw_vg");
const newTempFile = templateDoc.makeCopy(tempFolder);
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
body.replaceText("{Date of Request}",info['Date of Request'][0]);
body.replaceText("{Requestor}",info['Requestor'][0]);
body.replaceTest("{Line}",info['Line'][0]);
body.replaceText("{Cost Centre}", info['Cost Centre (if known)'][0]);
body.replaceText("{Project Name}", info['Project Name'][0]);
body.replaceText("{Project Code}", info['Project Code'][0]);
body.replaceText("{PN}", info['Part Number or Serial Number'][0]);
body.replaceText("{Reason for Requirement}", info['Reason for Requirement'][0]);
body.replaceText("{Quantity}", info['Quantity'][0]);
body.replaceText("{Description}", info['Description'][0]);
body.replaceText("{Have}", info['Have these products been deemed scrap by the Linelead/Area owner?'][0]);
openDoc.saveAndClose();
const blobPDF = newTempFile.getAs(MimeType.PDF);
const pdfFile = pdfFolder.createFile(blobPDF).setName(info['Requestor'][0] + " " + info['Date of Request'][0]);
tempFolder.removeFile(newTempFile);
return pdfFile;
}
I am no coder and any guidance on this would be greatly appreciated
"Ce message et toutes les pièces jointes (ci-après le "message") sont établis à l'intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l’expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusionou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. L'internet ne permettant pas d'assurer l'intégrité de ce message, nous déclinons toute responsabilité au titre de ce message, dans l’hypothèse où il aurait été modifié."--
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/4397fef2-d8f8-4923-ae85-fb2ecfd3cef8n%40googlegroups.com.