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
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Vishal Jaswal
Giga 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?
———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Ankur Bawiskar
Tera Patron
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader