How to fetch the January and February month open records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:17 PM
How to fetch the January and February month open records through script.
Please write a script above script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:24 PM
Hi,
By adding a query to your script you can specify what dates you want to get.
Providing an example below:
var incGR = new GlideRecord('incident');
incGR.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2023-01-01','00:00:00')^sys_created_on<=javascript:gs.dateGenerate('2023-02-28','23:59:59')");
incGR.query();
while (incGR.next()){
// your logic/actions here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:35 PM
@vinod6 Follow below steps
1) Go to list view of table from where you want to fetch records. Here I am going for an incident table. Add you filter like open records for January and February month.
2) Right click on filter and copy query
sys_created_onBETWEENjavascript:gs.dateGenerate('2023-01-01','00:00:00')@javascript:gs.dateGenerate('2023-02-28','23:59:59')^stateIN1,2,3,4
3) Put the copied query as parameter in addEncodedQuery method as below
var incGR = new GlideRecord('incident');
incGR.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2023-01-01','00:00:00')@javascript:gs.dateGenerate('2023-02-28','23:59:59')^stateIN1,2,3,4");
incGR.query();
while (incGR.next()){
//write you logic here
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:41 AM
@vinod6If I could help you with your Query then, mark my answer as Correct !!