Can I know the logic for getting incidents which is "In Progress" for last 10 days

Roshini
Giga Guru

Hi Team,
Can I know the logic for getting the incidents which is "In progress" for last 10 days.
I need the background script for this.
Can Someone help me to get it.

10 REPLIES 10

Vrushali  Kolte
Mega Sage

Hello @Roshini ,

 

Please find below the script -

 

var gr = new GlideRecord('incident');
gr.addQuery('state', '2'); // 2 is the value for "In Progress"
var tenDaysAgo = gs.daysAgoStart(10);
gr.addQuery('sys_updated_on', '<=', tenDaysAgo);
gr.query();

while (gr.next()) {
    gs.log('Incident ' + gr.number + ' has been in progress for more than 10 days.');
}

 

If my answer solves your issue, please mark it as Accepted and Helpful based on the impact.

Thanks for your reply,
but this will be giving the incidents which is "In Progress" and not updated for last 10 days.
But my requirement is to get the list of incidents which may or may not be updated but the state is "In Progress" for last 10 days.

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Roshini 

 

You can try the below script:

 

var gr = new GlideRecord('incident');
    gr.addQuery('state', '2');
	gr.addEncodedQuery('sys_updated_onRELATIVEGT@dayofweek@ago@10');
    gr.query();

    while (gr.next()) {
        gs.print('Incident Number: ' + gr.number + ' | Updated On: ' + gr.sys_updated_on);
    }

 

Thanks and Regards

Sai Venkatesh

but this will be giving the incidents which is "In Progress" and not updated for last 10 days.
But my requirement is to get the list of incidents which may or may not be updated but the state is "In Progress" for last 10 days.