GlideURL, decodeURL not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 05:59 PM
Hi All
Issue: The custom UI action and catalog client script which auto-populates values on the catalog request item form is not working on the test instance after I moved from dev.
This issue was due to the DOM manipulation code in catalog client script
var url = document.URL.parseQuery();
For various reasons ServiceNow do not recommend using DOM manipulation lines in the script and suggested to replace the DOM manipulation with OOB solution to identify URL parameters.
With this Client script, I am able to auto populate the variable value, but the issue I'm facing is the value is not getting decoded. Eg: %A0ARIELLE%20RODRIGUEZ%A0
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var name = gUrl.getParam("sysparm_fullname");
g_form.setValue('fullname', (name));
}
I tried decoding this way g_form.setValue('fullname', decodeURL(name));
Upon doing this, I am not getting the value.
Any thoughts or suggestions?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 07:04 PM
Check these out:
https://community.servicenow.com/community?id=community_blog&sys_id=596dea29dbd0dbc01dcaf3231f96190b
http://sncommander.com/how-to-get-parametersvalues-from-a-url-in-servicenow/
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 08:43 PM
Hi,
You can use decodeURIComponent(name);
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var name = gUrl.getParam("sysparm_fullname");
g_form.setValue('fullname', decodeURIComponent(name));
}
https://www.w3schools.com/jsref/jsref_decodeuricomponent.asp
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2019 06:42 AM
Hi Alikutty,
Thank you for the update, I also tied using ecodeURIComponent but no luck.
Regards
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2020 06:08 PM
Achacko, any luck? I am facing the same issue to decode an url.