Automatic Case Closure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2023 10:29 PM
Hello ,
I want the requests of custom table to automatically gets close if no action and response is taken for 15 days.
Please assist.
Thanks in advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2023 10:42 PM
Hi @Naga14 ,
Hope you are doing well.
For this you need to create one scheduled job and make it run daily
Please take the reference of OOB customization for incident table
- Navigate to System Scheduler > Scheduled Jobs > Today's Scheduled Jobs.
- Locate the record named Autoclose Incidents.
Please mark this response as correct or helpful if it assisted you with your question.
Regards,
Harshal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2023 12:02 AM
HI @Naga14 ,
I trust you are doing great.
- Create a new business rule in ServiceNow to handle the automatic closure of requests.
- Identify the custom table that contains the requests you want to monitor and close.
- Define the conditions that determine if a request should be closed. In this case, it would be if no action or response is taken within 15 days.
- Write a script in JavaScript to implement the logic for closing the requests. The script should perform the following steps: a. Query the custom table for requests that are open and have not been updated for 15 days. b. Iterate through the result set and close each request by updating the relevant field (e.g., status) with a closed status. c. Optionally, you can add a comment or update additional fields to indicate that the request has been automatically closed.
- Attach the script to the business rule and set it to trigger on the appropriate events (e.g., when a request is updated).
- Test the solution thoroughly to ensure it closes requests correctly and does not impact the performance of the system.
- Once tested, deploy the solution to the production environment.
(function executeRule(current, previous) {
var gr = new GlideRecord('your_custom_table_name');
gr.addQuery('active', true);
gr.addQuery('state', 'open');
gr.addQuery('sys_updated_on', '<=', gs.daysAgo(15));
gr.query();
while (gr.next()) {
gr.setValue('state', 'closed');
gr.setValue('close_notes', 'Automatically closed due to inactivity');
gr.update();
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 01:10 AM
Hi @Amit Gujarathi
Thanks for your respose!!
Will this work if i want Automatic Case Closure after inactivity of 15 days from the created date.