Your bug is related to the parameters you are passing into the function. Where you are calling the function docFile is the 9th parameter. Where the function is defined, docfile is the 10th parameter. Those two must be aligned, otherwise the value being sent in is being put in the wrong parameter.
Hope that helps.
This function works for one sheet in my file.function createBulkPDFs() {const docFile = DriveApp.getFileById("1jcRQ3MWZFLZFJ3sgpXEC-CQ6kdhScREuxzK3YnTGidw");const tempFolder = DriveApp.getFolderById("1GOKpDc32CrLIAqGnZimZu9LYynu8rhrn");const pdfFolder = DriveApp.getFolderById("1iau3rHSDqiPLlf1g9VZP1ckEAt0tmuH2")const currentSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("PDF - translation");const data = currentSheet.getRange(2,1,currentSheet.getLastRow()-1,21) .getValues();data.forEach(row => {createPDF(row[0],row[12],row[13],row[14],row[15],row[16],row[17],row[18],row[19],row[2],row[3],row[4],row[20],docFile,tempFolder,pdfFolder)})}function createPDF(jobnumber,startDate,startMonth,startYear,startHour,startMinute,endDate,endMonth,endYear,location,customer,reference,pdfName,docFile,tempFolder,pdfFolder) {const tempFile = docFile.makeCopy(tempFolder);const tempDocFile = DocumentApp.openById(tempFile.getId());const body = tempDocFile.getBody();body.replaceText("{jobnumber}", jobnumber);body.replaceText("{startdate}", startDate);body.replaceText("{startmonth}", startMonth);body.replaceText("{startyear}", startYear);body.replaceText("{starthour}", startHour);body.replaceText("{startminute}", startMinute);body.replaceText("{enddate}", endDate);body.replaceText("{endmonth}", endMonth);body.replaceText("{endyear}", endYear);body.replaceText("{location}", location);body.replaceText("{customer}", customer);body.replaceText("{reference}", reference);tempDocFile.saveAndClose();const pdfContentBlob = tempFile.getAs(MimeType.PDF);pdfFolder.createFile(pdfContentBlob).setName(pdfName);tempFolder.removeFile(tempFile);DriveApp.getFileById(tempFile.getId()).setTrashed(true);}I want to run another script for a different sheet in the same file. It's the same, just change in function name and fields. I created a new script file. And the second script always returns "TypeError: docFile.makeCopy is not a function". I tried creating new folders for the doc file, temp folder, PDF folder; and using the same folders for both scripts - none worked. This is the second script:Can anyone help? Thanks a lot!--
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 visit https://groups.google.com/d/msgid/google-apps-script-community/3abfa34f-810b-4c56-a3fa-59cfb1945167n%40googlegroups.com.