Reputation: 191
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
Upvotes: 8
Views: 5313
Reputation: 2005
UPDATE 2022-09-05 :
This is not wroking anymore since the old version of editor is now closed !
OBSOLETE :
I get the same issue. I fix it by switching to old version of the editor, and publish the app using the old editor version.
That's worked for me.
Upvotes: 0
Reputation: 16
Confirmed, it's a bug in the new version of the editor. Changing to the old version of the editor and publishing the web app fixed the issue for me.
Usually, the URL for every release/publish of your script stays the same. But with the new editor it appears that the publishing URL is changed, whereas the ScriptApp.getService().getUrl()
is returning the "old" URL.
But even more weird is the fact that the publishing of the "Test Web App" version seems to work fine, just the deployed version doesn't reflect the changes?
Upvotes: 0
Reputation: 38426
From https://issuetracker.google.com/issues/170799249#comment30 (my own comment)
Few days ago Google make it possible to create and assign a version for an existing deployment. See Release Notes 2021-03-15
Upvotes: 1
Reputation: 19339
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.
Upvotes: 7