Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Equals sign not being recognized in scripted URL

chrisshellhamme
Tera Expert

I have a scripted URL as the following:

 

var url = window.location.host + '/rm_story_list.do?sysparm_query=cmdb_ci=' + grTS.cmdb_ci_service + '^active=true';
window.open(url, '_blank', 'width=800,height=600');
 
The window is opening without the second equals sign:
 
/rm_story_list.do?sysparm_query=cmdb_ci%3Df6d8ba836f0ee2006a17d5267b3ee4cb%5Eactive%3Dtrue
 
Anyone have any thoughts as to why the second one is being omitted?
1 ACCEPTED SOLUTION

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @chrisshellhamme - Try like this:

 

var service = grTS.getValue('cmdb_ci_service');

var baseUrl = window.location.protocol + '//' + window.location.host + '/rm_story_list.do?sysparm_query=';
var query = 'cmdb_ci=' + encodeURIComponent(service) + '^active=true';
var url = baseUrl + encodeURIComponent(query);

window.open(url, '_blank', 'width=800,height=600');

View solution in original post

7 REPLIES 7

Also, depending on where this script is implemented, you may be able to use just the relative path in the baseUrl:

var baseUrl = '/rm_story_list.do?sysparm_query=';

 

 

Hi @sheldondotswift

This worked!  Thanks for your help!

Arya123
Tera Expert

hi @chrisshellhamme ,

please try the below code:

 

var baseUrl = window.location.host + '/rm_story_list.do';

var query = 'cmdb_ci=' + encodeURIComponent(grTS.cmdb_ci_service) + '^active=true';

var url = baseUrl + '?sysparm_query=' + encodeURIComponent(query);

window.open(url, '_blank', 'width=800,height=600');