I'm interested in generating a Google Document with a particular Apps Script from my library. The way I have been creating the Documents has been through basically, Jeff Everhart's code as seen here.
Is it possible that the code be changed as to have the new Google Docs have an embedded Apps Script right from the get go?
My reduced code:
function createNewGoogleDocs() {
const googleDocTemplate = DriveApp.getFileById('The template ID goes here');
const destinationFolder = DriveApp.getFolderById('The destination folder ID goes here');
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
const rows = sheet.getDataRange().getValues();
rows.forEach(function(row, index) {
if (index === 0 ) return;
if(row[rows[0].length - 1]) return;
const copy = googleDocTemplate.makeCopy(`First Column Name (${row[0]})`, destinationFolder);
const doc = DocumentApp.openById(copy.getId());
// Hopefully here we can have the addition of the the Apps Script on the new Docs
doc.saveAndClose();
const url = doc.getUrl();
sheet.getRange(index+1, rows[0].length).setValue(url);
})
}
new Google Docs have an embedded Apps Script. Can I ask you about the detail of it?