0
votes

I am trying to publish a spreadsheet as a web app through the script code embedded in another spreadsheet.

  • I want to copy a spreadsheet
  • I want to publish the copied spreadsheet as a web app
  • I want to retrieve the public url of the web app interface just created
  • I want to get the result of the doGet() function embedded in the copied spreadsheet

Thanks to Tanaike's help I wrote this code:

 // Copies the spreadsheet
 var repliesFile = responseTemplate.makeCopy('risposte', newFolder);

 // Publish the spreadsheet (Drive Api is enabled)
 Drive.Revisions.update({published: true, publishedOutsideDomain: true, publishAuto: true}, repliesFile.getId(), 1);
 var webAppUrl = "https://docs.google.com/spreadsheet/pub?key=" + repliesFile.getId();

Problem: using webAppUrl I can see the published spreadsheet but what I want is the html returned by the doGet() function in the copied spreadsheet. In a few words, the same interface I get if I publish the web app via 'Publish -> Deploy as Web App'. Is there a way to get it? A few images are attached (don't mind the template variables in the html template).

Thanks for all the help you can give me!

doGet() funtion in the copied spreadsheet embedded code the web app interface I get via 'Publish -> Deploy as Web App' what I get with my code

1
Hello, to understand you question better, can you please provide the content of webApp.html and the link to your previous post where you were helped by Tanaike? And maybe your spreadsheet after removing private information. - ziganotschka

1 Answers

0
votes

To obtain the URL of a WebApp you can use the method ScriptApp.getService().getUrl()

Note that this method will only work once you deployed the script as a Web App. And the WebApp will only work as intended if it contains a doGet() function.