0

I need to programmatically create a file based on a template Google Docs, and then process the document with a bound Script.

My initial approach was to create a bound script to the template file; then, using the google client library (for php, ruby, or w/e), copying the template into the actual document, and finally call the Script function on the newly copied document.

The problem is it seems you have to "publish" your bound App Script, and even after copying a document with a published bound script, the resulting file's script is not published.

Is there any way to copy the document and publish it's bound script directly from my PHP/Ruby/etc app?

PS: The reason I'm using bound script rather than just a script, it's because I need to store data using the PropertiesService.getDocumentProperties() in order to replace some variables with a "preview" function

Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206

1 Answers1

0

I think there's a misconception about boundscripts. You call them boundscripts because " it was created from that document " Tools -> Script Editor unlike standalone scripts which are created from script.google.com directly.

You don't have to publish boundscripts in order to use them. Those are called add-ons.

Now with regard to copying documents in Apps Script, try checking out copy() from DocumentApp. There's also a code snippet available in this SO thread with that demonstrates copyong which might give you insight.

Hope that helps.

Community
  • 1
  • 1
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56