- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 02:08 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 05:11 AM
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();
}
mark the solution as correct and helpful if it solves your issue.
Regards,
Kalyan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 03:50 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 03:54 AM
@Abhijeet Pawar Can you remove the gr.initilaize()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 03:55 AM
@Abhijeet Pawar also add the condition gr.addQuery('sys_updated_on','>',gs.daysAgo(5));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 04:20 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2023 04:02 AM
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 mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.