Reputation: 57
The below Google script is failing with error -
Document is missing (perhaps it was deleted, or you don't have read access?)
on line var body = DocumentApp.openById(NewdocumentId).getBody();
of the code below.
I am running the code from same account/script the new document copy is getting generated and then trying to access it the error occurs, what am I missing here???
//Copy the template to new folder
var NewdocumentId = DriveApp.getFileById('MyValidDocIDHere').makeCopy().getId();
DriveApp.getFileById(NewdocumentId).setName(row_no + '_' + customer.checkout+ '_' + customer.name + '_' + customer.room);
Utilities.sleep(9000);
var body = DocumentApp.openById(NewdocumentId).getBody();
body.replaceText("##DATE##", customer.checkin);
NewdocumentId.saveAndClose();
Upvotes: 1
Views: 519
Reputation: 57
I found the solution, as this was a Google Sheet SpreadsheetApp.openById
was to be used and not DocumentApp.openById
, some old examples on the internet made me copy this mistake over :(
Upvotes: 1