Make a URL dynamic

NiloferS
Tera Contributor

https://exampletest.service-now.com/$pa_dashboard.do?sysparm_dashboard=4756****dbc4bc103450****d3961...

 

This URL leads to a dashboard on test instance. How to make this URL a dynamic URL for dev and prod instances. I am making use of this URL in a client script.

3 ACCEPTED SOLUTIONS

Anurag Tripathi
Mega Patron
Mega Patron

HI,

You can use the below property to build the URL dynamically

gs.getProperty("instance_name")+".service-now.com";

OR

gs.getProperty('glide.servlet.uri')

PS, they both run server side so you may need to pass it using a display BR  

-Anurag

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@NiloferS 

no need to make it dynamic

Simply make it relative like this

/$pa_dashboard.do?sysparm_dashboard=4756****dbc4bc103450****d3961...

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Pratiksha Lang1
Kilo Sage
 
Below code works on server side:
 
var instanceURL = gs.getProperty('glide.servlet.uri');
var endPoint_URL = instanceURL+ '$pa_dashboard.do?sysparm_dashboard=58c3b187***72300117b******'; 

 

gs.log(endPoint_URL);
 
If you want this to work on client script then use below code:
 
script include :
 

 

var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	helloWorld:function() { 
		
		var instanceURL = gs.getProperty('glide.servlet.uri');


		return instanceURL; 
	} ,

	type: 'HelloWorld'
});

 

 

client script :

 

 

var ga = new GlideAjax('HelloWorld');
	ga.addParam('sysparm_name', 'helloWorld');

	ga.getXML(HelloWorldParse);

	function HelloWorldParse(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		alert(answer+ '$pa_dashboard.do?sysparm_dashboard=58c3b187***72300117b******';); 
}

 

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

HI,

You can use the below property to build the URL dynamically

gs.getProperty("instance_name")+".service-now.com";

OR

gs.getProperty('glide.servlet.uri')

PS, they both run server side so you may need to pass it using a display BR  

-Anurag

Ankur Bawiskar
Tera Patron
Tera Patron

@NiloferS 

no need to make it dynamic

Simply make it relative like this

/$pa_dashboard.do?sysparm_dashboard=4756****dbc4bc103450****d3961...

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Pratiksha Lang1
Kilo Sage
 
Below code works on server side:
 
var instanceURL = gs.getProperty('glide.servlet.uri');
var endPoint_URL = instanceURL+ '$pa_dashboard.do?sysparm_dashboard=58c3b187***72300117b******'; 

 

gs.log(endPoint_URL);
 
If you want this to work on client script then use below code:
 
script include :
 

 

var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	helloWorld:function() { 
		
		var instanceURL = gs.getProperty('glide.servlet.uri');


		return instanceURL; 
	} ,

	type: 'HelloWorld'
});

 

 

client script :

 

 

var ga = new GlideAjax('HelloWorld');
	ga.addParam('sysparm_name', 'helloWorld');

	ga.getXML(HelloWorldParse);

	function HelloWorldParse(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		alert(answer+ '$pa_dashboard.do?sysparm_dashboard=58c3b187***72300117b******';); 
}