server script hostname

Dave Clemmer
Mega Guru

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.

3 REPLIES 3

Ahmmed Ali
Mega Sage

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

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

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?

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

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali