Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

escaping special characters in search

IanGlencross
Kilo Expert

My LDAP is occasioanlly putting some junk into my sys_user table.   In particular it is inserting a carat (^)   character every now and again.

I was hoping to do a quick search for the carat (^)   character but search won't do it, neither will the URL based   https://<BASE>.service-now.com/sys_user_list.do?sysparm_query=user_nameLIKE^   as service now uses ^ as a logical "and".   I have to tried encode ( %5E) but this has no effect.

How do I escape this charater (and other special characters) in either of these scenarios?   Or do I need to write some regex ( /^\S*\^\S*$/) and run it in a script?

1 ACCEPTED SOLUTION

1
2
3
4
5
6
7
var rec = new GlideRecord('sys_user');
rec.addQuery('user_name', "CONTAINS", "^");
rec.query();
while (rec.next()) { 
var str = 'Found user with carat: ' + rec.user_name + '          sys_id: ' + rec.sys_id;
 gs.print(str);
}


(Better formatting...)


View solution in original post

5 REPLIES 5

Cool, good to hear. Yeah sounds like time for some updates indeed!!! Please mark as "correct answer" or "helpful answer" so this post can be marked as "answered". Thanks!