Error in addEncodedQuery: GlideTime - unparseable date: invalid function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 08:22 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2023 09:31 PM
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()";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 09:49 PM
Actually, this page is rendering ":" into ":", but actually it's this ":" colon in the query.