Autoclose Knowledge Feedback tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 02:22 AM
When a KB Feedback Task has been in the Resolved State for more than 2 Days (48 Hours), it should be automatically moved to the Closed state. help me with the best solution.
thanks in advance,
regards
saikumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:47 AM
Depending on how you are looking at it, you could create a scheduled job, run it daily and close all of the ones that have been resolved longer than 48 hours.
Or you create a flow that triggers on resolving a task, add a 48 hour wait and then close it (including logic for reopening and such).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 04:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 04:13 AM
You are triggering it only once. So the first update the record gets, will trigger the flow and then never again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 04:31 AM
Hi @kumar junior11,
This is easily achieved by creating a Scheduled Job.
Simply type 'Scheduled Job' and click on the entry under 'System Definition'. Create a new job and set a time this should run daily using the following code in the 'Run this script' field:
autoCloseKBF();
function autoCloseKBF() {
//var daysAgo = gs.getProperty('kbf.autoclose.time'); // Best practice and recommendation - Create a system property so this value can easily be changed or hardcode as below
var daysAgo = '2'; // hardcoded value
var daysAgoNumber = parseInt(daysAgo);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-daysAgoNumber);
if (daysAgoNumber > 0) {
var kft = new GlideRecord('kb_feedback_task');
kft.addEncodedQuery('state=6');
kft.addQuery('u_resolved_at', '<', queryTime);
kft.query();
while (kft.next()) {
kft.state = '3';
kft.active = false;
//kft.work_notes.setJournalEntry('Feedback Task automatically closed after ' + daysAgoNumber + ' days in the Resolved state.'); // Uncomment if you wish to add a worknote - recommended.
//kft.setWorkflow(false); //uncomment this line if you don't want to trigger other business rules/log etc
kft.update();
}
}
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie