1

​​I have created a script that copy template table from one docs to another.

function onOpen() {
  var ui = DocumentApp.getUi();
  ui.createMenu('Templates')
      .addItem('some_items', 'appendTemplate')
      .addToUi();
}

​function appendTemplate() {
    var sourcedoc = DocumentApp.openById("DocID");
    var sourcebody = sourcedoc.getBody();
    var tables = sourcebody.getTables();
    var table = tables[0].copy();
    var destdoc = DocumentApp.getActiveDocument();
    var destbody = destdoc.getBody();
    var x = destbody.appendTable(table)
}

When I exec this script the table correctly copy to target document but dropdown boxes are without default colours.

when I tried to click any of them I got an error "unable to load file".

Rubén
  • 34,714
  • 9
  • 70
  • 166
michu
  • 11
  • 1

1 Answers1

1

As the time this answer was posted, the Documents Service (Class DocumentApp) hasn't methods to handle dropdowns, only for Smart Chips (see Release note August 23, 2021). This might explain the issue.

I don't think that there might a workaround to use Google Apps Script or the Documents API to copy a dropdown without having the erro.

Resources

Related

Rubén
  • 34,714
  • 9
  • 70
  • 166