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.

addEncodedQuery Method In Lower Case Results are Strange instead of Error

Rahul Priyadars
Tera Sage

Hi All

 

in one my script i used below and results are as expected.

 

var incGr = new GlideRecord('incident');
var cn=0;

incGr.addEncodedQuery('active=true^reassignment_count>2');

 

Now i did this and it is returning all incidents instead of throwing syntax error.

 

var incGr = new GlideRecord('incident');
var cn=0;

incGr.addencodedquery('active=true^reassignment_count>2');

 

why i tested this in some of  the env my junior developers used lower case method name resulting into more records fetched and it updated more no of records causing issue.

 

I tested both versions above and behavior with lowercase is really Strange.

 

Am i missing something here . Please put some light on this .

 

Regards

RP

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

The second method is invalid, so it is ignored.  Anything in a GlideRecord that cannot be interpreted is ignored, so the query, in this case, results in returning all records.  It's not a syntax error, rather you are calling a method that does not exist.  Same if your query contained an error like omitting the ^ or mistyping a field name.