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.

How to fetch list of records from database table with a query string containing special charachters and spaces?

ranadip1
Kilo Explorer

i have a data base field named as "short_description" in a table customer . I want to fetch list of records from the table with a query string like this;

 

var gr = new GlideRecord('customer');

gr.addQuery('short_description','abc , cfg rth_as@abc.com');

gr.query();

while(gr.next())

{

/* some actions performed */

 

 

}

 

 

-------------------------------------------------

 

the query does not fetch any records from the table customer............... is there any other way to query with that particular string value to fetch data with exact matches?

5 REPLIES 5

mstoner
Kilo Contributor

Something else you could try is to do a Show Matching in the list the record is sitting in, then pull the query for that match:



http://wiki.servicenow.com/index.php?title=Encoded_Query_Strings#Generating_Encoded_Query_Strings_th...



From there, put it into your script as an Encoded Query.



GlideRecord - ServiceNow Wiki



I've had better luck that way occasionally.