Both decodeURIComponent() and decodeURI() not work on scoped application

Antonio42
Kilo Guru

Team, I am trying to decode an URL, but I am getting undefined value. Could you guys know how to resolve it?
Find below my code:

function getParameterValue(pName){

    var glideURL = new GlideURL();
    glideURL.setFromCurrent();
    var url = glideURL.getParam(pName);

    return decodeURI(url[pName]);
    //return decodeURIComponent(url[pName]);
}

 

15 REPLIES 15

Ankur,

The redirect is working fine, as I said in the beginning the decode is not working and I have special characters in my output.

Hi Antonio,

Are you having onLoad client script on that catalog item? Are you saying the onLoad client script is not able to get the correct url? If the redirect is working fine then the script should get the correct url.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

Yes, the script is getting the correct URL, but the decode is not working on it. If I set up the decode then I receive a result as "undefined", if not the result shows special characters (%) like this (XX)%XXXXX-XXXX.

The I assume the decode is not working well, Am I right?

Hi Antonio,

Are you saying because there is special character in some parameter value decode is not working?

Can you please alert the url and past the screenshot here?

Also instead of GlideStringUtil.urlEncode try this:

encodeURIComponent

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Is there any update on this? Is this question resolved or you need some more assistance.

Please consider marking my reply as Correct & 👍Helpful.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader