I've currently got an editable Google Sheet with data in specific cells and a clean, mostly static template Google Doc file with placeholder text to receive values from Google Sheet data which I then save to a PDF.
At the moment, I do the following to create a copy of the template Google Doc into a temp folder, ready to replace the text placeholders in the Doc with values from the Sheet:
let newCMRbody = DocumentApp.openById(DriveApp.getFileById(cmrTemplateId).makeCopy(tempFolder).getId()).getBody();
Doing the above takes around 4-5 seconds which isn't a lot but combined with other calls in the script is causing noticeable delays.
Is there a way to store a copy of the template Google Doc as a variable in the script so that it doesn't have to go out and get it each time? Or can the value be stored in a cache?
When I do: Logger.log(JSON.stringify(newCMRbody));
It's just showing an empty object: {}