How to auto close the completed RITM after 5 business days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 03:07 AM
Below is the Scheduled job that i have written to auto closed the Completed RITM after 7 days. but as per the requirement it should auto close the RITM after 5 business days only excluding sat sun and holidays , is it possible ?
var gr = new GlideRecord("sc_req_item");
gr.addEncodedQuery("active=true^state=16^u_completed_onRELATIVELT@dayofweek@ago@7");
gr.query();
while (gr.next()) {
var requestedfor = gr.requested_for;
gr.state = '3';
gr.close_code = "Solved (Permanently)";
gr.close_notes = "Closing resolved ticket";
gs.eventQueue('Auto-Closure Requested item', gr, requestedfor);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 03:12 AM
It is doable and you will need to create a schedule (or use any existing) . Check this out,
How to close ticket after 3 business days - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 03:58 AM
Hi @VIKAS MISHRA
On your above script, main change should be "@business_time" keyword, instead of "@dayofweek". This keyword will ensure that only business days are counted, which excludes weekends and holidays. Also, you need to make sure, your instance has configured business hours and holidays. If you do, ensure to use right keyword as mentioned.
Please let me know if you have additional query.
Thanks,
Vamshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 06:31 AM
Can you please provide me with exact query what i need to put
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 07:56 AM
Hi @VIKAS MISHRA
Just apply and change your query on above code, something like this.
gr.addEncodedQuery("active=true^state=16^u_completed_onRELATIVELT@business_time@5");
And ensure you check if your instance is configured business hours and holidays.
Please mark helpful/correct, if your query is addressed and/or answered!
Thanks,
Vamshi