Dynamic instance URL in client script

Luis Roman
Kilo Guru

I have a client script that I need to get the instance for the URL in order to generate the URL for a catalog item to shown. Because I am in a client script I can not use gs.getProperty('glide.servlet.uri'). Is the only way to get the URL is through the use a client script and script include (AJAX)?

For example; I need to get "https://dev58970.service-now.com/" depending on the environment that I am. Like development, UAT or production.

Your expert advise or guidance will be appreciated.

 

2 REPLIES 2

Mike_R
Kilo Patron
Kilo Patron

Yes use AJAX to retrieve sys_properties client side.

 

This post shows an alternative method, using BR to set the scratchpad value and client script to get the scratchpad value. But I would recommend just going the AJAX route.

https://www.servicenow.com/community/it-service-management-forum/how-to-get-system-property-at-clien...

 

G24
Kilo Sage

If you are in Catalog Client Script, you may be able to use one of the following:

 this.location.href

 this.location.origin