Please help me out with below error.
TypeError: Cannot read property 'namedValues' of undefined
As I am new in Google Apps Script. i want to generate PDF and send to requester on his email id. Please review my script below and suggest.
function afterformsubmit(e){
const info = e.namedValues;
createPDF(info);
}
function createPDF(info){
const pdfFolder = DriveApp.getFolderById("1nV1zSSJfBND0ao9NufmIOEa_ocO5DhQf");
const tempFolder = DriveApp.getFolderById("1u3vbM1hxqKThVMsnjLeLWqLn3CWdTMDO");
const templateDoc = DriveApp.getFileById("1qBtaAfcsHmxU9Y4wp6uQRdFkR95XhVNqpr6tDQ2xH7Q");
const newTempFile = templateDoc.makeCopy(tempFolder);
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
body.replaceText("{dt}", info['PO Date'][0]);
body.replaceText("{dpt}", info['Department'][0]);
body.replaceText("{rname}", info['Requestor Name'][0]);
body.replaceText("{item}", info['Item 1'][0]);
body.replaceText("{qty}", info['Qty1'][0]);
body.replaceText("{price}", info['Unit price1'][0]);
openDoc.saveAndClose();
const blobPDF = newTempFile.getAs(MimeType.PDF);
const pdfFile = pdfFolder.createFile(blobPDF).setName(info['Requestor Name'][0] + " " + info['Department'][0]);
tempFolder.removeFile(newTempFile);
return pdfFile;
}