Error in addEncodedQuery: GlideTime - unparseable date: invalid function

Mehant Kumar
Kilo Contributor

I'm trying to run a simple background script which counts number of record in incident table which is created yesterday.

var gr = new GlideRecord('incident');
var myQuery = "sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()";
gr.addEncodedQuery(myQuery);
gr.query();
var count = 0;
while (gr.next()) {
 count++;
}
gs.print("Count: " + count);

 When I run this there's this error: "GlideTime - unparseable date: invalid function" is getting printed multiple times, equal to the number of records satisfying the query.

 

Thanks

2 REPLIES 2

nancystodd
Tera Expert

The colons in the encoded query need to be changed from an HTML entity (:) to just a plain colon character.

 

Replace the following line:

var myQuery = "sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()";

 

with this:

var myQuery = "sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()";

 

Actually, this page is rendering ":" into ":", but actually it's this ":" colon in the query.