1

I have a template file in Google Docs. This template is to be copied and the newly created document presented to the user for editing in the browser.

I have a webapp where the user clicks a button and that runs the following code:

var theTemplate = DriveApp.getFileById('[ID_of_the_template');
var theDocument=theTemplate.makeCopy("copy_for_me");
var num=theDocument.getId();
Logger.log(num);

This makes the copy and then in the variable "num" I have the document ID I need and all I now need is to open a link to https://docs.google.com/document/d/[docuID_here]/edit but I can find no way to do so.

I am sure this is easy but I can not find how to do it. Maybe I am thinking too complicated or am on the wrong track. As always I appreciate any and all help.

Greetings from the Bavarian Alps.

  • Check this [SO question](http://stackoverflow.com/questions/10744760/google-apps-script-to-open-a-url) if it can help you. – KENdi Dec 04 '16 at 11:47
  • Than you @KENdi. This is the route that I took. It is not as "elegant" as I had hoped for but it works sucessfully. – Neill Hogarth Dec 12 '16 at 20:55

1 Answers1

0

See the accepted answer here. I do not believe this has changed in the past 3 years. Basically, the portion of the script which creates the file is run on the server.

That said, IF your web app has a client side, you may be able to return the file link back to the client side and display it as a link for the user to open.

Community
  • 1
  • 1
Karl_S
  • 3,364
  • 2
  • 19
  • 33
  • Thank you for taking the time to help me. I had seen and read this answer but had hoped that as I am running my script as a webapp and this refers to a spreadsheet, there may be a method. I had also hoped that in the last few years there may have been an improvement in the situation. Coming from a php background, I thought this would be something that was so obvious no one wrote about it. But now I will look for a different solution. Thank you again. – Neill Hogarth Dec 01 '16 at 21:55