How to Get the URL and Parameters in a Scoped Application Client Script
I needed to retrieve the current URL and one of its parameters in a client script in a scoped application.
Scoped application don't have access to the window object, so it can't be used for this purpose.
After experimenting with no success on many other approaches, I found out about the GlideURL class.
Here's how I retrieved the URL and sysparm_target parameter in the client script:
var glide_url = new GlideURL();glide_url.setFromCurrent();
var target = glide_url.getParam("sysparm_target");
The documentation for GlideURL doesn't include setFromCurrent(), which pulls information about the current URL into the newly created GlideURL object.
If anyone knows about other useful function calls in GlideURL, please share them in the comments.
https://www.servicenow.com/community/developer-articles/how-to-get-the-url-and-parameters-in-a-scoped-application-client/ta-p/2330371