Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Not applicable

What is the best way to determine if the instance is prod or sub-prod from a UI Script?

8 REPLIES 8

edwin_munoz
Mega Guru

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.


Not applicable

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.


ahaz86
Mega Guru

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);


}


Shannon Thurston in my example you could replace the "instance_name" with "glide.installation.production" to get the true/false value