- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:22 PM
How can I set the state of an Incident to "Closed" automatically after a certain number of days?
Solved! Go to Solution.
- 1,642 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:28 PM
Hi @mahesh009 ,
You can use Business rule or Schedule Job or Flow Designer for this.
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Manikanta. Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:35 PM - edited ‎09-29-2024 10:39 PM
Hi @mahesh009 ,
To automatically set the state of an Incident to "Closed" in ServiceNow after a certain number of days, you can use either a **Scheduled Job** or a combination of a **Business Rule** and **Scheduled Script Execution**. A Scheduled Job can run daily, checking for incidents that have been resolved for a specific number of days (e.g., 7 days) and update their state to "Closed". Alternatively, a Business Rule can trigger upon incident resolution to set a closure date, and a scheduled script can then update incidents to "Closed" after the specified time has passed. Both approaches ensure incidents are closed automatically based on the defined criteria.
regards
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:36 PM
Hi @mahesh009
We can write a schedule item and business rule to close the incident after few days.
In the advanced tab you can write the script for autocloseincidents()
Using glide record hence you can close the incident.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 11:20 PM
Hi @mahesh009
we can use the schedule job and business rule to close the incident after few days.
in advanced tab you can write the script in schedule job
var gr = new GlideRecord('incident');
gr.addQuery('state', '!=', '6'); // Assuming '6' is the Closed state
gr.addQuery('sys_created_on', '<=', gs.daysAgo(30)); // Adjust the number of days
gr.query();
while (gr.next()) {
gr.state = '6'; // Set to Closed
gr.update();
}
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Venkata Sai Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 11:41 PM
Hi @mahesh009
To automatically close incidents in ServiceNow after a certain number of days, you can use one of two methods:
1. Scheduled Job: Runs daily to find incidents that have been resolved for a specific time (e.g., 7 days) and updates their status to "Closed."
2. Business Rule and Scheduled Script: A Business Rule sets a closure date when an incident is resolved, and a scheduled script closes those incidents after the specified period.
Both methods ensure incidents are closed automatically.
Thanks, and Regards
Vishaal
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 12:52 AM
Hi @mahesh009 ,
You can achieve this via creating a Schedule job which is the best way to get your job done.
Refer these conversations to perform this..
https://www.servicenow.com/community/itsm-forum/incident-autoclosure-in-5-business-days/m-p/447432
===================================***************=========================================
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thanks & Regards,
Aditya
=====================================***********==========================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:28 PM
Hi @mahesh009 ,
You can use Business rule or Schedule Job or Flow Designer for this.
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Manikanta. Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:35 PM - edited ‎09-29-2024 10:39 PM
Hi @mahesh009 ,
To automatically set the state of an Incident to "Closed" in ServiceNow after a certain number of days, you can use either a **Scheduled Job** or a combination of a **Business Rule** and **Scheduled Script Execution**. A Scheduled Job can run daily, checking for incidents that have been resolved for a specific number of days (e.g., 7 days) and update their state to "Closed". Alternatively, a Business Rule can trigger upon incident resolution to set a closure date, and a scheduled script can then update incidents to "Closed" after the specified time has passed. Both approaches ensure incidents are closed automatically based on the defined criteria.
regards
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 10:36 PM
Hi @mahesh009
We can write a schedule item and business rule to close the incident after few days.
In the advanced tab you can write the script for autocloseincidents()
Using glide record hence you can close the incident.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 11:20 PM
Hi @mahesh009
we can use the schedule job and business rule to close the incident after few days.
in advanced tab you can write the script in schedule job
var gr = new GlideRecord('incident');
gr.addQuery('state', '!=', '6'); // Assuming '6' is the Closed state
gr.addQuery('sys_created_on', '<=', gs.daysAgo(30)); // Adjust the number of days
gr.query();
while (gr.next()) {
gr.state = '6'; // Set to Closed
gr.update();
}
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Venkata Sai Krishna