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/execVersioned Deployment ID:
AKfycbzR21YpWNakFEisFcW1zo-tArveQ5nXj_gTRYLF4OZWkMf_Gun8Q3I2WZncfLSbjKErMade some changes, created a new versioned deployment
ScriptApp.getService().getUrl()correctly returns https://script.google.com/a/gong.io/macros/s/AKfycbxXBdBXAV7olI0NGe-uS0_4FEFZPPNXLVHml6NNNW9zYf1fLOqfLhLYsaz6FTmjduIq/execVersioned Deployment ID:
AKfycbxXBdBXAV7olI0NGe-uS0_4FEFZPPNXLVHml6NNNW9zYf1fLOqfLhLYsaz6FTmjduIqWe'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/execVersioned 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.
- Deleted all versioned deployments and created a new one
- Disabled web app
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

getUrl()returns the/devURL if I have deployed a new version from manifest but haven't deployed the webapp viaPublish > Deploy as web app.... Could you please share the code related to the manifest file, in case I'm missing something? Also, when publishing asDeploy as web app..., the following message appears:A new link will be given when you click Update. The current link will continue to work. So it seems that when the web app is deployed this way, a new URL is generated that overrides the one created from manifest, but both work. - IamblichusDeploy as web app...not appropriate, and you want the ones corresponding to the versions deployed from manifest? - IamblichusScriptApp.getService().getUrl()is returning? If I have multiple versions deployed withPublish > Deploy as web app...? - yarinbenado