Best way to detect Prod or sub-prod from the client side?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 09:55 AM
What is the best way to determine if the instance is prod or sub-prod from a UI Script?
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 10:05 AM
Hello Shannon,
Can you give more details about your requirement?
You can use pure javascript to get the current url: javascript - Get current url in web browser - Stack Overflow
You can also create a function in a script include that returns the instance name and call it on the UI Script.
If you only need this UI script in certain table you can create a display business rule and create a scratchpad variable with the name of the instance.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 10:13 AM
Hi Edwin,
This is a UI Script that I use for our development team. The script is currently checking the URL and if it isn't production, I am replacing the nav_header_text with the instance name and Update Set name. That helps us make sure we are on the correct update set while we are working.
So far, I'm thinking I would need to create a little script include that I can call that will check the property, glide.installation.production.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 10:12 AM
Client Callable Script include (To get the instance in the UI Script)
var GetInstance = Class.create();
GetInstance.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getInstance: function() {
return gs.getProperty('instance_name');
}
});
In your ui script
getInstance();
function getInstance(){
var ga = new GlideAjax('GetInstance');
ga.addParam('sysparm_name','getInstance');
ga.getXMLAnswer(getInstanceParse);
}
function getInstanceParse(response){
alert(response);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 10:24 AM
Shannon Thurston in my example you could replace the "instance_name" with "glide.installation.production" to get the true/false value