Detecting Service-Now Environment in Script

sschleicher208
Kilo Contributor

We have several environments of our Service-Now instance (PROD/TEST/DEV).   We have a script that needs to call out to different versions of a web service depending on whether the call originated from a DEV instance or a PROD instance.   Is there any function/property accessible from the business rule script that can tell me what instance it's presently running on?   If so, I can use that to instantiate the correct web service and make the call.

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Stephen,



If you want to fetch the instance name from the script. You can fetch the property value i.e "instance_name" from the sys_properties table.


View solution in original post

4 REPLIES 4

sschleicher208
Kilo Contributor

Seems like I may be able to use the following to read the host: var headerValue = g_request.getHeader("host"); but this doesn't work when I access the "g_request" object.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Stephen,



If you want to fetch the instance name from the script. You can fetch the property value i.e "instance_name" from the sys_properties table.


epam
Kilo Guru

Hi,



you may use following: RP.getReferringURL() to get your instance name



P.S. How to access a URL inside g:evaluate tag in Jelly


User658880
Tera Expert

I grab the instance name property like this

    if (gs.getProperty('instance_name') == 'test') {  // IF TEST INSTANCE

Your instances should have this property set differently.