Both decodeURIComponent() and decodeURI() not work on scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 04:37 AM
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]);
}
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:41 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 09:49 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 10:14 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 01:24 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 08:42 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader