Getting the URL from Server Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 02:56 AM
Hello,
Is there a way to capture the URL/URI in Server Script of a widget in the INITIAL load of the page?
*location, *window, getUrlOnStack are either returning null or undefined.
getGlideURI() - is returning not exactly the URI from the URL address. The '=', '&' are converted to different format such as '%3d', '%26'.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 03:01 AM
You can get the instance URL by getting the below property.
var instanceURL = gs.getProperty('glide.servlet.uri');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 03:18 AM
Thanks Vino but that only returns the static portion of URL. I want to capture the part after that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 06:04 AM
Hi,
please try this in server side script
var url = gs.action.getGlideURI().toString();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 07:38 AM
I ended up using getGlideURI() [my 2nd option] but added decodeURIComponent() to get rid of symbol transformation.
decodeURIComponent(gs.action.getGlideURI());
Thanks for looking into this.