- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 03:43 AM
how to specify condition in addQuery() to return records of a specified date.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 03:47 AM
Can you please elaborate your requirement?
You can use EncodedQuery like below. You can check out this document for encoded query:
Sample script:
var dat = "sys_created_onON2019-07-24@javascript:gs.dateGenerate('2019-07-24','start')@javascript:gs.dateGenerate('2019-07-24','end')";
var gr = new GlideRecord('incident');
gr.addEncodedQuery(dat);
gr.query();
while(gr.next()){
gs.print(gr.number);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2019 03:53 AM
Hi there,
You could just generate your query thru a List in the Platform UI. Generating the query with your specified date using the Condition Builder. Then simply right mouse click, Copy query.
Within a GlideRecord, you could use addEncodedQuery and just paste (and maybe slightly modify) your query in between the (' ');
gr.addEncodedQuery("sla_dueON2019-08-05@javascript:gs.dateGenerate('2019-08-05','start')@javascript:gs.dateGenerate('2019-08-05','end')");
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field