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
‎06-03-2021 04:00 PM
I got this to work, in a client script it reads from the URL and extracts the variables/parameters so I can populate onLoad in my form.
function onLoad() {
var user, comm;
var gUrl = new GlideURL();
gUrl.setFromCurrent();
user = decodeURI(gUrl.getParam("sysparm_requested_for"));
comm = decodeURI(gUrl.getParam("sysparm_description"));
g_form.setValue('requested_for', user);
g_form.setValue('comments', comm);
}
However it does not address when the parameters are blank, it will result in "undefined" values set in the form fields.