Need to Auto close the ticket from resolved to closed after 7 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2022 11:03 PM
Need to Auto close the ticket from resolved to closed after 7 days.I have written a scheduled job script but its not working. Pls help me in this.
var query = 'state=8^sys_updated_onRELATIVELT@dayofweek@ago@7'; //state is resolved
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery(query);
gr.query();while(gr.next()){
gr.state = '3'; //set the state to closed
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2022 11:08 PM
Hi Shewta,
Please check this article: How to Auto Close ‘Resolved’ Incidents after 7 days in Service Now
old thread: How to Auto close incidents in 5 working days, after incident state is resolved.
Thanks!
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2022 11:11 PM
Hi
You can take reference of OOTB Business Rule:
Link: https://<your_instance_name_here>.service-now.com/sys_script.do?sys_id=d67b8d9ec0a80118008cd8f0f7f92fae
This Business Rule is for autoclosing the Incidents after certain days (days are provided in the System Properties which you can find in the Business Rule itself ). So you can make a copy of this Business Rule and adjust it as per your requirements.
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 10:32 PM
Hi
Is your issue resolved or are you still facing it?
Please mark my answer as correct if my previous reply solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2022 11:11 PM
Hey,
Your code looks fine except for if you want to close a ticket, why are you querying "sc_task"?
Can you clarify if you are trying to close a catalog task or incident?
If incident, you need to add incident in the gliderecord
Aman Kumar