query records on specified date

Sravan Kumar Ka
Tera Contributor

how to specify condition in addQuery() to return records of a specified date.  

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

Can you please elaborate your requirement?

You can use EncodedQuery like below. You can check out this document for encoded query:

https://docs.servicenow.com/bundle/madrid-platform-user-interface/page/use/using-lists/task/t_GenEnc...

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

Thank you,
Abhishek Gardade

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

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 (' ');

find_real_file.png

gr.addEncodedQuery("sla_dueON2019-08-05@javascript:gs.dateGenerate('2019-08-05','start')@javascript:gs.dateGenerate('2019-08-05','end')");

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn