The CreatorCon Call for Content is officially open! Get started here.

GlideURL not working in OnLoad catalog client script while trying to fetch one of the URL parameters

sharan16
Tera Contributor

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?

7 REPLIES 7

Still getting the same error.  I think the below code also need to be replaced.

if (!value) {
   var gUrl = new GlideURL();
    gUrl.setFromCurrent();
    value = gUrl.getParam("sysparm_id");
    return value;
        }

sharan16_0-1698039135801.png

 

Hello @sharan16 

 

var myparm = getParmVal('sys_myparm');
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}