server script hostname
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:18 AM
I have found a need to get the hostname as part of a business rule that is running (I need to know if a URL that is part of the record being inserted is going to this instance of Servicenow, essentially), and I haven't found a way to do that. It seems like it should be trivial; can someone point me to something I've undoubtedly missed?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:27 AM
Hello @Dave Clemmer
There is a system property called instance_name. This property value will be your instance name and you can read this value in business rule to create full URL and match the same with your URL field value (if the entered URL contains the instance URL).
Example:
var thisInstanceURL = gs.getProperty('instance_name') + ".service-now.com";
var enteredURL = current.YOUR_URL_FIELD.toString();
if(enteredURL.indexOf(thisInstanceURL) > -1){
gs.info("The URL is pointing to this instance");
}
Thank you,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 07:03 AM
Hmm... that did not work, although it would make sense to me that it's a misconfiguration that it didn't. Our instances are on-prem; can we rename our instances, or is that something we need to get ServiceNow support involved with?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 08:09 AM - edited 07-17-2023 08:09 AM
Hello @Dave Clemmer
The instance_name and glide.servlet.uri properties doesn't work for on-premise instances. You may have to hard-code the URL in script or contact ServiceNow to check if there is any dynamic way.
Thank you,
Ali
Thank you,
Ali