- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 07:33 AM
Hi ServiceNow Community Developers,
Do you know if there is a way to identify through a script which instance you are on? For instance I have 3 properties that I have defined for dev, test and prod. Right now in dev I have a hard-coded dev property in my script. When I move my code to test I need to remember to change the code to reference the test property and the same thing when I move to prod, I will also need to remember to change the property. Is there a way to dynamically figure out which property to use based on the instance I am on? For instance how can I say - if dev then use this property, if test then use this one and if prod then use that one, something like that. Please advise.
Thanks,
Johannes
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 07:36 AM
You could do:
var instanceName = gs.getProperty('instance_name');
If your instance was dev44665.service-now.com it would return just dev44665. You can also use:
var instanceURL = gs.getProperty('glide.servlet.uri');
This would return your entire instance base URL.
Please mark my answer as helpful/correct if it resolved your issue!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 07:36 AM
You could do:
var instanceName = gs.getProperty('instance_name');
If your instance was dev44665.service-now.com it would return just dev44665. You can also use:
var instanceURL = gs.getProperty('glide.servlet.uri');
This would return your entire instance base URL.
Please mark my answer as helpful/correct if it resolved your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 07:39 AM
Wow, that does work indeed. Thanks a lot Elijah!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2019 12:23 PM
The other way of doing it is you have 1 System Property and you use a Clone Data Preserver to preserve the values in the sub-prod instances. That way you just always use the same property, it would just contain different values in the different instances.
That way you don't have to worry about or check to see what instance you are in.