Filter ritm by range

tsoct
Tera Guru

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?

 

tsoct_0-1721751671280.png

 

1 ACCEPTED SOLUTION

Vrushali  Kolte
Mega Sage

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👍!

View solution in original post

1 REPLY 1

Vrushali  Kolte
Mega Sage

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👍!