- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 09:21 AM
I want to query RITM that are in progress between 2024-07-18 and 2024-07-19 from the list of RITMs using actual start and end fields. How can I filter the range so that just the requests listed below are returned?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 09:42 AM - edited 07-23-2024 09:43 AM
Hello @tsoct ,
You can use below script -
// Define the start and end dates
var startDate = '2024-07-18 00:00:00';
var endDate = '2024-07-19 23:59:59';
var gr = new GlideRecord('sc_req_item');
gr.addQuery('actual_start', '<=', endDate);
gr.addQuery('actual_end', '>=', startDate);
gr.query();
var ritmList = [];
while (gr.next()) {
ritmList.push(gr.getValue('number')); // or use gr.sys_id if you want the sys_id
}
gs.print('RITMs in progress between ' + startDate + ' and ' + endDate + ': ' + ritmList.join(', '));
If you want to make it dynamic you can create a function in SI and pass start & end date as parameters.
If my answer solves your issue, please mark it as Accepted ✔️and Helpful👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 09:42 AM - edited 07-23-2024 09:43 AM
Hello @tsoct ,
You can use below script -
// Define the start and end dates
var startDate = '2024-07-18 00:00:00';
var endDate = '2024-07-19 23:59:59';
var gr = new GlideRecord('sc_req_item');
gr.addQuery('actual_start', '<=', endDate);
gr.addQuery('actual_end', '>=', startDate);
gr.query();
var ritmList = [];
while (gr.next()) {
ritmList.push(gr.getValue('number')); // or use gr.sys_id if you want the sys_id
}
gs.print('RITMs in progress between ' + startDate + ' and ' + endDate + ': ' + ritmList.join(', '));
If you want to make it dynamic you can create a function in SI and pass start & end date as parameters.
If my answer solves your issue, please mark it as Accepted ✔️and Helpful👍!