The CreatorCon Call for Content is officially open! Get started here.

after 5 days Auto close incident those are in resolved state

Abhijeet Pawar
Tera Contributor

Hello All,

I want to automatically close resolved incident after 5 days .how can I achieve this functionality can anyone please guide me on this?

Thank You.

1 ACCEPTED SOLUTION

Hi @Abhijeet Pawar ,

from navigation select scheduled job > click new> select "Automatically run a script of your choosing"
and write the code which you want to check and also remove gr.initilaize() from your code then save and click on Execute now 

for your reference below is the code 

var gr = new GlideRecord("incident");
gr.addQuery('state','6');
gr.query();
while(gr.next()){

gr.state = 7;
gr.close_code = 'Solution provided';
gr.close_notes = 'hello';
gr.active = false;
gs.log("Incident has closed");
gr.update();

}Screenshot 2023-01-20 at 6.40.04 PM.png




mark the solution as correct and helpful if it solves your issue.

 

Regards,

Kalyan

View solution in original post

11 REPLIES 11

Hello @Basheer @kalyan13 @Omkar Kumbhar @Neeraj Modi 

I have written one script in the schedule item but it's not working can anyone guide me one mistakes i am doing here?please check attach screenshot.

Thank You.

@Abhijeet Pawar Can you remove the gr.initilaize() 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

@Abhijeet Pawar also add the condition gr.addQuery('sys_updated_on','>',gs.daysAgo(5));

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Hello @Omkar Kumbhar  just for testing purpose i want to check is it working or not so which is method should i used gs.minutesAgo(2) but its not working

 

Hi @Abhijeet Pawar ,

You need to remove gr.initialize() from your script.

Where did you kept the logic of 5 days? It doesn't seem to be in your script.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.