EncodedQuery to pull out incidents updated 2 days ago?

dianemiro
Kilo Sage

Hi Everyone,

I'm trying to pull out incidents via background script that is updated 2 days ago. But it returns 0 record. But when I checked manually on the list. There are records that are last updated 2 days ago. Thank you so much for your help.

Regards,
Diane

1 ACCEPTED SOLUTION

dianemiro
Kilo Sage

I was able to create an EncodedQuery for this and it gives me the results I need. Regardless, thank you all for your response.

gr.addEncodedQuery('sys_updated_onBETWEENjavascript:gs.daysAgoStart(2)@javascript:gs.daysAgoEnd(2)');

View solution in original post

11 REPLIES 11

Ahmmed Ali
Mega Sage

Hello,

 

follow below steps:

1. Open incident list view and set the query as you want and run it.

2. Once page loads, right click on the query (next to filter icon in list view) and click on copy query.

 

In script, add GlideRecord_variable_name.addEncodedQuery("paste_here");

 

also still issue persists, please post your script.

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi Ali,

I appreciate your response. The issue is when I try to set Updated Relative on 2 days ago, it does not return any record. So using it as the encoded query won't also achieve what I am looking for.

Regards,
Diane

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Dianes,

So you can use that query which you ran on the list in the background script and check once in that encoded query

copy the query

var gr = new GlideRecord('incident');

gr.addEncodedQuery(encQuery);

gr.query();

var rowCount  = gr.getRowCount();

see screenshot below; use copy query and add that query in the above encoded query

find_real_file.png

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thank you so much for your response. You're always helpful. The issue is when I try to set Updated Relative on 2 days ago, it does not return any record. So using it as the encoded query won't also achieve what I am looking for.

Regards,
Diane