I use a script to update a Google doc template by making a copy of it and editing its contents.
I then want to send that updated copy via email as a PDF attachment. I managed to get the email and the PDF attachment with the correct file name etc., but the contents of the PDF are of the template. When I go to the doc file in google drive, I see that it is updated but for some reason the one that comes in the email isn't.
I even set a sleep timer for up to 5 seconds to see if maybe drive is taking some time to update the changes in the doc.
I tried the same thing with an older document and the contents were updated so I am guessing it's a matter of time. Is there any way for me to force an update on the document when it is created rather than adding a long sleep timer? Do I need to manually save the new doc in the script before emailing it?