Need to remove 'nav_to.do?' from BR constructed URL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 11:47 AM
I want to copy variables from a custom table (like new_call) to the catalog item chosen. I am using logic from Brad Tilton to move over the custom table sys_id in URL constructed from the Business Rule.
https://community.servicenow.com/community?id=community_blog&sys_id=596dea29dbd0dbc01dcaf3231f96190b
I added a sysparm value to the url"+" sysparm_newcall_sysid=" + current.sys_id;
The BR constructs the URL fine and I see it with a log statement. Unfortunately, the instance adds the default 'nav_to.do?' to the URL which causes the on load client script to get a null value for my parameter. If I manually cut and paste the URL from the log (without the nav_to.do?) the client script gets the value successfully.
Is there a way to remove part of the default URL path, specifically the nav_to.do?
The onload client script need to work for a Service Portal catalog item, so no document or window commands please. Thank you!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 12:15 PM
Could you describe a little more about what you're doing here and include the code from the business rule? What does the final url look like?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 12:33 PM
Hello Brad, My BR is similar to others such as the New Call changed to Request. It includes:
var sysid=current.sys_id;
var url="com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + reqitem+"&sysparm_newcallid=" +GlideStringUtil.urlEncode(sysid);
gs.log(url);
action.setRedirectURL(url);
So my log url looks great. And if I manually paste it into the URL (after the instance) my onload client script returns the newcall sysid.
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var mycall = getParameterValue('sysparm_newcallid');
if (mycall) {
g_form.setValue('call_record', mycall);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
So the problem seems to be that the new call redirect to the catalog includes the "nav_to.do?uri=" after the instance instead of just going to /com.glide etc. Isn't there an easy way to redirect without that nav extension?
Thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 12:42 PM
You can probably do that with an absolute url like:
var url = gs.getProperty('instance_name') + '.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqitem + '&sysparm_newcallid=' +GlideStringUtil.urlEncode(sysid);
The thing you lose with removing nav_to.do?uri= is the leftnav and instance header, though. I think I've used this in the past with the nav_to.do?uri= in the url successfully but I'd need to go test that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 12:57 PM
Good idea but no, even the hard coded adds the leftnav back. If this were an application menu I could put window=_blank. Is there a way to go straight to the catalog or SP view of this catalog item without the left nave included?