Weird Behaviour with DriveApp.getFileById()

六眼飞鱼酱① 提交于 2019-12-02 02:53:09

From your script, I thought that it might be required to use saveAndClose(). So in your script, for example, please add it before var attatchment = DriveApp.getFileById(doc.getId()); as follows.

var subject = "See attatched";
doc.saveAndClose(); // Added
var attatchment = DriveApp.getFileById(doc.getId());

Reference:

Additional information:

At the classes of DocumentApp, SpreadsheetApp and SlidesApp, when the Doc is modified by the methods of each class, in the case that the script is running, the modifications are reflected by saving the Doc using the save method. On the other hand, at Google APIs of Sheets API and Slides API, when each method is called and run, the modifications are reflected, even if the script is running. At Google Document, there is no Docs API yet. But recently, the form about the early access of Docs API is released. When Docs API got to be able to be used, I think that the methods of API might be able to edit and save the document without using saveAndClose().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!