Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Auto Close the ticket after 7 days when the state is "Awaiting Response"

MS17
Tera Contributor

Hi All,

 

I want to close the ticket automatically after 7 days if the state changed to "Awaiting Response" and no response received from the user, how to achieve this. Please suggest.

 

Thanks.

15 REPLIES 15

Yes, i got it, this is my use case 

chipillasra
Tera Contributor

Hi @MS17 ,

write a schedule job 

var gr = new GlideRecord('your_table_name');
gr.addQuery('state', 'Awaiting Response'); 
gr.addQuery('sys_updated_on', '<=', gs.daysAgo(7));
gr.query();

while (gr.next()) {
gr.state = 'Closed'; 
gr.work_notes = 'Auto-closed due to no response within 7 days.';
gr.update();
}

Ankur Bawiskar
Tera Patron

@MS17 

this is for which table?

You can have a daily scheduled flow and check it using conditions.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

this is for universal request table

@MS17 

then you can follow how OOB incident auto closure is done and enhance for your table

Customizing incident auto-closure 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader