GlideURL not working in OnLoad catalog client script while trying to fetch one of the URL parameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 03:01 AM
GlideURL not working in esc portal - OnLoad catalog client script while trying to fetch one of the URL parameters.
(There is a JavaScript error in your browser console)
Below is the OnLoad catalog client script
function onLoad() {
//Type appropriate comment here, and begin script below
var num = getParameterValue('sysparm_universal_request');
if (num) {
g_form.setValue('ur', num);
}
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
value = gUrl.getParam("sysparm_id");
return value;
}
}
Is there any alternative way to fetch url parameters?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 04:21 AM
Hello @sharan16
Plz follow the below link ro solve your query :-
https://sncommander.com/how-to-get-parametersvalues-from-a-url-in-servicenow/
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 05:52 AM
Hello @sharan16
You can use below script-
var myparm = getParmVal('sys_myparm'); function getParmVal(name){ var url = document.URL.parseQuery(); if(url[name]){ return decodeURI(url[name]); } else{ return; } }
Plz mark my solution as Accept, If you find it helpful .
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2023 11:17 PM
Still getting the same error. I think the below code also need to be replaced.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 06:42 AM
Hi,
Try below.
var myparm = getParmVal('sysparm_universal_request');
if (myparm) {
g_form.setValue('ur', myparm);
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}