How to Close Problem Records automatically after 5 days ???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 08:56 AM
Hey Community,
I want to auto-close the problem records that are resolved after 5 days. I have so far followed below steps :
1. Created a Business Rule with below script :
// This script automatically closes problems that are resolved
// and haven't been updated in the specified number of days.
// This number is a property in System Properties.
// To place a comment in the incident, uncomment the "gr.comments" line..
autoCloseProblems();
function autoCloseProblems() {
var ps = gs.getProperty('glide.ui.autocloseproblem.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
if (pn > 0) {
var gr = new GlideRecord('problem');
gr.addQuery('state', 6);
// gr.addQuery('sys_updated_on', '<', queryTime);
gr.addQuery('sys_updated_on', ''<'', gs.daysAgo(pn));
gr.query();
while(gr.next()) {
gr.state = 7;
// gr.comments = 'Problem automatically closed after ' + pn + ' days in the Resolved state.';
gr.active = false;
gr.closed_by = gr.resolved_by;
gr.update();
}
}
}
2. Created a Schedule Item
3. Created a system property : glide.ui.autocloseproblem.time
I tried adding 1 min as trigger as well as 1 hour trigger in schedule item. But still above configuration is not working. Kindly let me know what am I doing wrong ??
As I see we do have OOTB for Incidents autoclosure but not for problems. Please help me with the requirement.
Thanks,
Hritik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2022 09:48 PM
Glad to see my answer helped you, Kindly mark the answer as Correct & Helpful both such that others can get help.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2023 01:49 AM
Hi
Hritik
can you help me can i get full code for this requirement how you have achieved for problem.
Regards
Jyothinath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 06:47 AM
Hello Hritik
Could you please me to get the complete code in order to fulfill the requirement ?
Thanks in advance
Nagurbee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 01:27 PM
@Community Alums @Nagurbee1 and anyone else looking for a clean answer to this:
Use Flow Designer!
- Trigger: Scheduled Daily
- Action 1: Look up records with the following conditions:
- State is Resolved, and
- Updated | Relative | Before | 7 Days ago, and
- Resolved | Relative | Before | 7 Days ago
- Action 2: For each item in Action 1
- Action 3 in the 'For each loop' from Action 2: Update Record with the following fields:
- Problem state | Closed
- State | Closed
- Work Notes | "System auto-closed Problem after being in Resolved state for 7 days"
- Closed by | Action 2 > Problem Record > Resolved by