The CreatorCon Call for Content is officially open! Get started here.

Existing script/method to reliably determine if instance is Production

The SN Nerd
Giga Sage
Giga Sage

I'm looking for a way to determine if an instance is Production.

I noticed there is a system property, glide.installation.production

property.PNG

However, this is set to true on every instance!

On HI, the instance in question is listed correctly as being Non-Production.

hi.png

Is there a reliable, configuration agnostic way to tell from within the instance if it is Production or not?


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
2 ACCEPTED SOLUTIONS

GlideUtil.isProductionInstance()



However this is not available in Scoped Code.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

JeffPatt
Tera Expert

As Dominic and Daniel have mentioned, the accepted solution is not correct at all.

 

For my use case I ended up setting a new System Property to store the name of the Production instance and a function in an open-access global scope Script Includes that performs an equality check against instance_name.

It's not OOTB, but has advantages in that it doesn't modify existing properties, and works.

View solution in original post

9 REPLIES 9

Mihir Mohanta
Kilo Sage

1.You can create a new property and mark production instance by setting some values there.


2.In script use gs.getProperty() method to call this property and find out instance is production or not.



Thanks,


Mihir


This needs to be a solution that can be applied to any given instance without any manual intervention.


Otherwise I'd just change the property that already exists and use that.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

GlideUtil.isProductionInstance()



However this is not available in Scoped Code.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

It should be noted that this API Call relies on the underlying system property: "glide.installation.production"



This will define the value that is returned, being either true or false.