Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Characters that cannot be used in "sysparm_query=" in "g_navigation.open"

bonsai
Mega Sage

I ran the following script as a UI action:
(Client is checked)

 

 

g_navigation.open('incident.do?sys_id=-1&sysparm_query=description=test');

 The above worked fine, but the following didn't:

g_navigation.open('incident.do?sys_id=-1&sysparm_query=description=test80%')

 

I found out that "%" couldn't be used, so I used "encodeURIComponent" and it worked.

I wonder if there were any other characters that couldn't be used besides "%"...
I wanted to check if there were any problems with past records, but I would like to know if the problem occurs with strings other than "%"...

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@bonsai 

best to use encodeURIComponent before sending anything to any URL so that it gets rendered and populates correctly.

some other characters which should be encoded as per my understanding-> % < > " [] {}

You should get the list from google as well

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Vishal Jaswal
Tera Sage

Hello @bonsai 

 

incident.do?sys_id=-1&sysparm_query=short_descriptionLIKEtest%25off%20%26%20urgent

 

 

  • %25 → used in LIKE queries
  • %20 → space.
  • %26 → ampersand (&) as part of the value, not a new parameter.

 


Hope that helps!

glideFather
Tera Patron

I am not aware of any other alternative than encodeURIComponent:

Something like this, not tested:

var query = 'description=' + encodeURIComponent('test80%');

g_navigation.open('incident.do?sys_id=-1&sysparm_query=' + query);


Did the encodeURIComponent work for you?

✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

Ankur Bawiskar
Tera Patron

@bonsai 

best to use encodeURIComponent before sending anything to any URL so that it gets rendered and populates correctly.

some other characters which should be encoded as per my understanding-> % < > " [] {}

You should get the list from google as well

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader