DocumentApp 服务抛出 "Service Documents failed while accessing document with id" 错误

DocumentApp service throws a "Service Documents failed while accessing document with id" error

我正在为 Google 文档创建一个脚本,它从我所在的当前文档中获取每个元素并将其复制到另一个文档中(基本上是制作副本)。

duplicateDocument();

function duplicateDocument() {
  var currentDoc = DocumentApp.getActiveDocument().getBody();
  var targetDoc = DocumentApp.create('Speech Doc');
  var totalElements = currentDoc.getNumChildren();

  //Goes through each type of element to preserve formatting
  for( var index = 0; index < totalElements; ++index ) {
    var body = targetDoc.getBody();
    var element = currentDoc.getChild(index).copy();
    var type = element.getType();

    if( type == DocumentApp.ElementType.PARAGRAPH ){
      body.appendParagraph(element);
    }
    else if( type == DocumentApp.ElementType.TABLE){
      body.appendTable(element);
      }
    else if( type == DocumentApp.ElementType.LIST_ITEM){
      body.appendListItem(element);
      }
    else if( type == DocumentApp.ElementType.BOOKMARK ){
      body.appendBookmark(element);
    }
    } 
}

我一调用这个函数,就弹出这个错误:

访问 ID 为 [目标文档 ID] 的文档时服务文档失败

这段代码在一两天前就可以工作了……是什么原因?

问题是我在要复制的文档中添加了脚注。

删除脚注后,它可以很好地复制文档。

编辑:我在 Google 的 IssueTracker

上开了一个问题