Automatic Case Closure

Naga14
Tera Contributor

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!!

3 REPLIES 3

Harshal Aditya
Mega Sage
Mega Sage

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

  1. Navigate to System Scheduler > Scheduled Jobs > Today's Scheduled Jobs.
  2. Locate the record named Autoclose Incidents.

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

 

Amit Gujarathi
Giga Sage
Giga Sage

HI @Naga14 ,
I trust you are doing great.

  1. Create a new business rule in ServiceNow to handle the automatic closure of requests.
  2. Identify the custom table that contains the requests you want to monitor and close.
  3. 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.
  4. 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.
  5. Attach the script to the business rule and set it to trigger on the appropriate events (e.g., when a request is updated).
  6. Test the solution thoroughly to ensure it closes requests correctly and does not impact the performance of the system.
  7. 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



Naga14
Tera Contributor

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.