How to pass special characters in URL sysparm_query to populate form fields

skumars1808
Tera Contributor

I need to autopoulate change description from a url. The change description and contain special characters.

Please help how can I send the special characters through a url.

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Use encodeURIComponent() to escape the characters like so:

'/change_request.do?sys_id=-1&sysparm_query=description=' + encodeURIComponent(current.description) 

 

For more info refer to:

https://www.w3schools.com/jsref/jsref_encodeuricomponent.asp

View solution in original post

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

I need to populate the description of a new change form through the URL. I am forming the URL through a UI Action as below:

'/change_request.do?sys_id=-1&sysparm_query=description=' + current.description 

But when the description is having special character like "#" then it does not work. Without special characters it is working fine.

Willem
Giga Sage
Giga Sage

Use encodeURIComponent() to escape the characters like so:

'/change_request.do?sys_id=-1&sysparm_query=description=' + encodeURIComponent(current.description) 

 

For more info refer to:

https://www.w3schools.com/jsref/jsref_encodeuricomponent.asp