H
ere’s a quick tip that shows you how to retrieve the name or URL of your Service-now instance. This can come in handy if you need to construct a URL in a business rule or mail script or if you have some automated post-clone configuration when dealing with multiple Service-now instances in your environment.
Each instance has a property stored in the ‘sys_properties’ (System Properties) table that stores the name of your instance. The name of the property is (unsurprisingly) ‘instance_name’. You can find the value of this property via any server-side script (Business Rules, etc.) by using the ‘gs.getProperty’ method like this…
If you need to get the full URL for your instance you can get it from the ‘glide.servlet.uri’ property the same way…
Here’s a useful function that I’ve seen used before to create an html link for a specific record. All you need to do is pass in the table name and sys_id of the record and the function returns the html.
return "<a href=" + gs.getProperty('glide.servlet.uri') + gs.generateURL(strTableName, strSysID) + ">LINK</a>";
}
Hi Mark,
This is very useful information.
I am looking for similar method to find URL of a site created by us. We have created a site with prefix Booking, now I want to find the site using command so that I can create different welcome page for this site.
I tried using above method for site, but it is not working as it will return the instance not the actual URL.
ND
That’s correct. This returns instance URLs. I don’t have an equivalent currently that handles CMS site URLs.
I’m not sure exactly what you are looking for, but can you use “window.location” in your script to get the URL of the page you are on and then check the value of that string???