- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 01:05 AM
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
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 04:55 AM
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)');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 01:10 AM
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
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 02:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 01:16 AM
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
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2019 02:09 AM
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