Instance name or base URL

psiek
Kilo Contributor

Hi,

I need to have base url our instance name, because , as we have 3 instances, we cannot hard code links. (I can't find a way to use ${URI} or ${URI+} in   blocs in templates)

Regards,

8 REPLIES 8

Damn html interpreter :



function CreateLinkForObject(strTableName, strSys_id)
{
return "<a href=\"" gs.getProperty("glide.servlet.uri") + gs.generateURL(strTableName, strSys_id) + "\">LINK</a>";
}


Jace Benson
Mega Sage

I had to find a way to get this in a client script. This worked for that;


var href = "https://" + window.location.host + "/ess";


Yasser Al Kindi
Tera Contributor

1- From the main developer page, click on your name in top right corner

2- Click on Manage instance password

3- Your URL is there

Swarup Patra
Kilo Guru

Sure, you can use the GlideSystem (gs) method 'getProperty' to get the base URL of your instance. Here's how you can do it:

1. Use the gs.getProperty() method to get the 'glide.servlet.uri' property, which holds the base URL of your instance.

javascript
var baseURL = gs.getProperty('glide.servlet.uri');


2. Now, you can use this 'baseURL' variable in your code wherever you need the base URL of your instance.

3. If you want to use this in an email script, you can do it like this:

javascript
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* EmailOutbound */ email, /* GlideRecord */ email_action, /* GlideRecord */ event) {
var baseURL = gs.getProperty('glide.servlet.uri');
template.print(baseURL);
})(current, template, email, email_action, event);


4. If you want to use this in a UI Page or UI Macro, you can do it like this:

xml

gs.getProperty('glide.servlet.uri')
${jvar_baseURL}

 

5. If you want to use this in a client script, you can do it like this:

javascript
var ga = new GlideAjax('GlobalAJAXProcessor');
ga.addParam('sysparm_name', 'getBaseURL');
ga.getXMLAnswer(function(answer) {
var baseURL = answer;
// use baseURL here
});


And in the 'GlobalAJAXProcessor' script include:

javascript
if (name == 'getBaseURL') {
return gs.getProperty('glide.servlet.uri');
}


Remember, the 'glide.servlet.uri' property should be set correctly in the System Properties for this to work.


nowKB.com

If you want to know any information about Service Now . Visit to https://nowkb.com/home