According to the documentation, this method should return the URL of the web app:
"Returns the URL of the web app, if it has been deployed; otherwise returns null. If you are running the development mode web app, this returns the development mode url."
We have a Google Calendar add-on in which we have custom settings page (html) delivered to the clients using HtmlService
and I have no idea how ScriptApp.getService().getUrl()
works with versioned deployments.
Here's an interesting scenario:
On a fresh Google Script project, we deployed from manifest file (NOT webapp, although we have the "webapp" part on the manifest)
First versioned deployment from manifest:
ScriptApp.getService().getUrl()
correctly returns https://script.google.com/a/gong.io/macros/s/AKfycbzR21YpWNakFEisFcW1zo-tArveQ5nXj_gTRYLF4OZWkMf_Gun8Q3I2WZncfLSbjKEr/exec
Versioned Deployment ID: AKfycbzR21YpWNakFEisFcW1zo-tArveQ5nXj_gTRYLF4OZWkMf_Gun8Q3I2WZncfLSbjKEr
Made some changes, created a new versioned deployment
ScriptApp.getService().getUrl()
correctly returns https://script.google.com/a/gong.io/macros/s/AKfycbxXBdBXAV7olI0NGe-uS0_4FEFZPPNXLVHml6NNNW9zYf1fLOqfLhLYsaz6FTmjduIq/exec
Versioned Deployment ID: AKfycbxXBdBXAV7olI0NGe-uS0_4FEFZPPNXLVHml6NNNW9zYf1fLOqfLhLYsaz6FTmjduIq
We've deployed the script through Publish->Deploy as web app... Probably done this mistakenly on our production script
Web app URL is https://script.google.com/a/gong.io/macros/s/AKfycbzv1gX4eim1CzTjnFc4sFNvLMw9mXCfOv4laDu-_9AKefk5jXg/exec
Another round of code changes to the script. This time we deployed from manifest:
ScriptApp.getService().getUrl()
incorrectly returns https://script.google.com/a/gong.io/macros/s/AKfycbzv1gX4eim1CzTjnFc4sFNvLMw9mXCfOv4laDu-_9AKefk5jXg/exec
Versioned Deployment ID: AKfycbx29Pcs8_cpEkodrfWGklz8t_OAs87OBSEtxLMkStrya64wUV4M2ePW_tNTTWlq0_T1
Notice that this time - we got the webapp deployment ID - not the versioned deployment id.
From here on, no matter what I've tried - I will ALWAYS get https://script.google.com/a/gong.io/macros/s/AKfycbzv1gX4eim1CzTjnFc4sFNvLMw9mXCfOv4laDu-_9AKefk5jXg/exec no matter what we do.
As of now, everything I do ends up in ScriptApp.getService().getUrl()
returning this URL.
How can I reset it and get getUrl()
to return the versioned deployment ID rather than a non-existing webapp deployment ID?
edit: typos
Store and share your projects in Google Drive or publish on the Chrome Web Store. Tutorials and guides to take you from writing your first script to building your application. From productivity tools to enterprise automation, see what you can build with Google Apps Script.
Apps Script is a rapid application development platform that makes it fast and easy to create business applications that integrate with G Suite. Build with Google Feature-rich APIs let you extend Google services and build your own web applications. Code on the Web A web browser is all you need to build with Google Apps Script.
Disables the script from being accessed as a web app. This method is equivalent to opening the "Publish > Deploy as web app" dialog and clicking "disable web app". Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.
The script does not need to // be published as a web app; the /usercallback URL suffix replaces /edit in any script's URL. // IMPORTANT: Replace string below with the URL from your script, minus the /edit at the end.
This issue was reported in Issue Tracker (I'm guessing you did it), and now it got forwarded internally. Posting this here to give it more visibility:
To anyone affected by this, please click the top-left star.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With