GlideURL, decodeURL not working

achacko
Kilo Guru

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?

5 REPLIES 5

Prateek kumar
Mega Sage

Alikutty A
Tera Sage

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!

Hi Alikutty,

Thank you for the update, I also tied using ecodeURIComponent but no luck.

 

Regards

Anil

Antonio42
Kilo Guru

Achacko, any luck? I am facing the same issue to decode an url.