Portal: GlideURL is not defined

cnu
Tera Contributor

I'm trying to capture the url parameter 'sysparm_comments' but I get the error 'ReferenceError: GlideURL is not defined'

What options do I have to capture the url 'sysparm' values from the url on Portal.

FYI: I cannot switch the type to 'Desktop' because I want it to work on the Portal

Here is my catalog client script code:

function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var comments = gUrl.getParam("sysparm_comments");
alert('comments');
}

url: https://<instance>/sp?id=cat_item&sys_id=6a8497441b99b4106c45b886d34bcb37&sysparm_comments=testing%20passing%20information

 

find_real_file.png

1 ACCEPTED SOLUTION

BALAJI40
Mega Sage

Hi, 

GlideUrl won't support here use the parse URL parameters in the client script.

Copy the same code from the below link and change the argument as per your requirement.

Parse URL Parameters in a Client Script - ServiceNow Guru

View solution in original post

4 REPLIES 4

BALAJI40
Mega Sage

Hi, 

GlideUrl won't support here use the parse URL parameters in the client script.

Copy the same code from the below link and change the argument as per your requirement.

Parse URL Parameters in a Client Script - ServiceNow Guru

The link is not available anymore.
Could you please share the solution again?

 

cnu
Tera Contributor

Thanks Balaji, 

 

Apparently that doesnt work too (I have actually tried that as my first option).  And this is what the author says in the article:

 

find_real_file.png

cnu
Tera Contributor

Thanks Balaji, 

 

There was some additional code at the bottom which worked fine.  Here is the full code:

 

function onLoad() {
    var comments = getParameterValue("sysparm_comments");
    alert(comments);
}

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]);
    }
}